Other PDF Issues

How to Reset a Text Field When Checking a Checkbox in PDF Forms

Ayan MasoodAyan Masood Nov 2, 2026 868 views

Question details

The user needs to reset a text field to its default value automatically whenever a specific checkbox is toggled to make the text field visible.

How to Reset a Text Field When a Checkbox Is Checked in PDF Forms
Product
Adobe Acrobat / PDF Form
Device & OS
not provided
Scenario
Setting up interactive PDF form fields where toggling a checkbox controls a text field's visibility and triggers a reset of its content.
Observed behavior
A checkbox successfully shows or hides a text field, but the text field retains old inputted data instead of clearing/resetting when it becomes visible again.
Before you start

Ensure your PDF editor supports JavaScript for interactive form properties. It is highly recommended to back up your original PDF file before adding custom scripts to prevent accidental data loss.

Solution 1Recommended

Use JavaScript in Checkbox Actions to Reset Fields

Add a custom JavaScript snippet to the checkbox properties to clear the target text field whenever the visibility condition is met.

By attaching an action script to the checkbox, you can command the document to reset specific text fields automatically based on the visibility condition. This ensures that hidden fields don't accidentally hold irrelevant data.

1
Enter form editing mode

Open your PDF document in your form editor (such as Adobe Acrobat) and enter 'Prepare Form' or 'Edit Form' mode.

2
Access checkbox properties

Right-click the specific checkbox that controls the visibility of your text field and select 'Properties' from the context menu.

3
Add a JavaScript action

Navigate to the 'Actions' tab. Select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the 'Select Action' dropdown, and click the 'Add' button.

4
Input the reset script

In the JavaScript editor window, enter a condition to check visibility, followed by the reset command. For example: `if (nHide == display.visible) { this.resetForm(["YourTextFieldName"]); }`. Replace 'YourTextFieldName' with the exact name of your text field.

5
Save and test

Click 'OK' to save the script, then close the properties window. Exit the form editing mode and toggle the checkbox to ensure the text field resets properly upon becoming visible.

Use JavaScript in Checkbox Actions to Reset Fields
Avoid Duplicate Field Names: Make sure to pass the exact field name inside the array. Remove duplicate field names from the reset array unless multiple separate fields must be reset simultaneously.
Professional PDF Solution

Easily Create and Manage Interactive PDF Forms with WPS Office

WPS Office includes a robust, built-in PDF editor that allows you to view, fill, and create interactive forms effortlessly. It natively supports comprehensive form field properties and actions.

  1. 1. Download and install: Download WPS Office for free from the official website and install it on your device.
  2. 2. Open your PDF: Launch WPS Office, go to the PDF tab, and open your existing PDF document or create a blank one.
  3. 3. Use form tools: Navigate to the 'Form' tab on the top ribbon to insert Text Fields, Checkboxes, and Dropdowns.
  4. 4. Customize properties: Double-click any inserted form field to edit its properties, format, and interactions to build your interactive document.
Create, edit, and fill interactive PDF forms with an intuitive interfaceHigh compatibility with standard PDF JS scripts and formats across Microsoft Office and AdobeLightweight and runs smoothly on Windows, Mac, iOS, and AndroidFree tools for text editing, merging, and signing PDFs directly
microsoft office alternative - wps office

Frequently Asked Questions

Can I reset multiple fields with one checkbox action?

Yes. In the JavaScript `this.resetForm([])` array, you can list multiple exact field names separated by commas. For example: `this.resetForm(["TextField1", "TextField2"]);`.

Why doesn't the text field clear when I uncheck the box?

The script triggers the reset based on your `if` condition (e.g., checking if the field is set to visible). To clear it when the checkbox is unchecked or hidden, you need to adjust your JavaScript logic to execute when the condition equals hidden or off.

How do I find the exact name of my text field?

In your PDF form editing mode, the field names are usually displayed directly over the fields as labels. You can also right-click the field and check its 'Properties' under the General tab to find, copy, or rename the exact field name.

Will this JavaScript work in all PDF readers?

Standard JavaScript form commands like `resetForm` are supported in most dedicated PDF readers (including Adobe Acrobat and WPS Office) but might be restricted or ignored in simplified web-browser PDF viewers.