Clear an Acrobat Checkbox When User Selects No in an Alert
Question details
The user needs to automatically uncheck a selected PDF form checkbox in Adobe Acrobat Pro if a user clicks No in an alert confirmation box.

- Product
- Adobe Acrobat Pro 2017
- Device & OS
- not provided
- Scenario
- Developing or editing interactive PDF forms using JavaScript to validate user selections.
- Observed behavior
- The developer needs a script that resets the checkbox value to Off when the response to the app.alert function evaluates to 3, which represents No.
Ensure you have access to edit the PDF form fields and that JavaScript execution is enabled in your PDF editor's preferences.
Use JavaScript to Reset the Checkbox Value
Add a custom JavaScript action to the checkbox properties to catch the alert response and reset the field.
In Adobe Acrobat, the app.alert method can return different values based on the button clicked by the user. A return value of 3 represents a 'No' selection. By checking this value, you can immediately set the event target value to 'Off', which clears the checkbox.
Open your PDF form in Adobe Acrobat Pro and enter 'Prepare Form' mode from the tools pane.
Right-click the specific checkbox you want to configure and select 'Properties' from the context menu.
Navigate to the 'Actions' tab. Select 'Mouse Up' as the trigger, choose 'Run a JavaScript' from the action dropdown menu, and click the 'Add' button.
In the JavaScript Editor window, paste the following script: if (app.alert('Confirm selection?', 2, 2) == 3) event.target.value = 'Off'; Then click 'OK' to save.
Close the properties window and exit 'Prepare Form' mode. Click the checkbox; when the alert appears, select 'No' to verify that the checkmark is removed.

Manage and Edit PDF Forms with WPS Office
If you are looking for an efficient way to manage interactive PDFs, WPS Office provides a powerful PDF editor. It supports viewing, filling, and editing PDF forms seamlessly across Windows, Mac, and mobile devices.
- 1. Open your PDF in WPS: Launch WPS Office and click on the 'PDF' tab to open your interactive document.
- 2. Access form tools: Navigate to the 'Form' tab in the top ribbon to view available interactive form tools and highlighters.
- 3. Edit or fill the document: Click directly on the checkboxes or text fields to interact with them, or use the editing tools to modify the document layout.

Frequently Asked Questions
Why doesn't the checkbox clear when I set the value to an empty string?
For standard PDF checkboxes, the unchecked state is typically represented by the specific export string 'Off', not an empty string (''). Setting the target value strictly to 'Off' ensures it clears properly.
Can I customize the text message in the alert box?
Yes, you can replace 'Confirm selection?' in the app.alert() function with any text string you want to display to the user, such as 'Are you sure you want to enable this option?'.
What happens if the user clicks 'Yes' in the alert box?
If the user clicks 'Yes', the app.alert function returns 4. Since the script only looks for a return value of 3 (which means 'No'), clicking 'Yes' bypasses the script and leaves the checkbox selected.
How do I test the JavaScript after adding it to the form field?
To test the script, you must exit 'Prepare Form' mode and click on the checkbox using the standard Hand or Select tool. The alert should pop up, and clicking 'No' should immediately uncheck the box.




