How to Reset Acrobat Form Fields and Restore Colors with JavaScript
Question details
The user needs to reset a PDF form using JavaScript while ensuring that dependent fields properly restore their background colors and editable states.

- Product
- Adobe Acrobat / PDF Editor
- Device & OS
- not provided
- Scenario
- Clearing a PDF form using a reset button where checkboxes normally control the visual formatting and read-only status of other dependent fields.
- Observed behavior
- The standard this.resetForm() command clears the checkboxes but fails to trigger their attached formatting scripts, leaving dependent text fields incorrectly grayed out or locked as read-only.
Ensure you have access to a PDF editor that supports creating and editing JavaScript for interactive form fields, such as Adobe Acrobat Pro or advanced PDF tools.
Append State and Color Restoration to the Reset Script
Directly update the field properties (like fill color and readonly status) immediately after calling the reset command on your reset button.
Because the this.resetForm() function clears values internally without triggering the 'Mouse Up' or 'Change' events of individual checkboxes, dependent scripts tied to those checkboxes do not run. Manually forcing the default appearance in the reset button's script solves this synchronization issue.
Open your PDF in your form editor and enter the 'Prepare Form' or 'Form Editing' mode to access interactive elements.
Right-click your Reset button and select 'Properties', then navigate to the 'Actions' tab.
Select 'Run a JavaScript' from the action list and click 'Edit'. Ensure your standard reset command like this.resetForm(); is at the top.
Below the reset command, add code to restore the dependent fields manually. For example: var f = this.getField('DependentField'); f.fillColor = color.white; f.readonly = false; Click 'OK' to save.

Adapt the Formatting Script into a Custom Calculation
Move the logic that changes the field color and state into a custom calculation script so it evaluates continuously based on the checkbox state, rather than relying on a click event.
Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing tools, allowing you to easily create interactive forms, add checkboxes, and manage form field properties to ensure a seamless document experience.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF tool.
- 2. Enter form mode: Navigate to the 'Form' tab on the top ribbon to access the interactive form controls panel.
- 3. Add and configure controls: Click on 'Push Button', 'Check Box', or 'Text Field' to add them to your page, then double-click the element to configure its appearance and properties.

Frequently Asked Questions
Why doesn't this.resetForm() trigger my checkbox scripts?
The resetForm method restores the default value of the fields internally but does not simulate a user physical click or change event. Therefore, any JavaScript attached specifically to the Mouse Up or Change trigger of the checkbox is bypassed.
Can I reset only specific fields instead of the whole PDF form?
Yes. You can pass an array of field names to the reset function. For example, using this.resetForm(["Field1", "Field2"]); will only clear the specified fields while leaving all other form data intact.
What is the correct syntax for defining the color white in Acrobat JavaScript?
In Acrobat JavaScript, you can use the predefined color array color.white. Alternatively, you can define it strictly in RGB format using ["RGB", 1, 1, 1] or as CMYK using ["CMYK", 0, 0, 0, 0].




