PDF Editing Issues

How to Add an OK or Cancel Warning Before Resetting a PDF Form

Natalie TaylorNatalie Taylor Oct 28, 2026 869 views

Question details

The user needs to display a confirmation dialog box (OK or Cancel) when a reset button is clicked in a PDF form to prevent unintentional deletion of form data.

How to Add an OK or Cancel Warning Before Resetting a PDF Form
Product
Adobe Acrobat / PDF
Device & OS
not provided
Scenario
Creating an interactive PDF form and configuring a reset button to clear user input safely.
Observed behavior
By default, a reset button instantly clears all form data. The goal is to intercept this action with a warning prompt that allows the user to confirm or cancel the reset.
Before you start

Ensure you have a PDF editor with form editing and JavaScript capabilities installed, and that your PDF already contains a configured interactive button field.

Solution 1Recommended

Add a JavaScript Action to the Reset Button

Replace the default 'Reset a form' action with a custom JavaScript snippet that triggers a confirmation popup before executing the reset command.

Using a simple JavaScript code allows you to intercept the button click. The script uses the app.alert method to display a question. If the user selects 'OK', the form clears; if they select 'Cancel', nothing happens.

1
Open Button Properties

Open your PDF form in editing mode. Right-click the Reset button you created and select 'Properties' from the context menu.

2
Remove the Default Reset Action

Navigate to the 'Actions' tab. If 'Reset a form' is listed in the Actions box, select it and click the 'Delete' button to remove the default behavior.

3
Add the JavaScript Action

In the 'Select Action' dropdown, choose 'Run a JavaScript' and click the 'Add' button to open the JavaScript Editor.

4
Input the Confirmation Code

Enter the following code: var nResponse = app.alert({cMsg: "Are you sure you want to clear all data?", nIcon: 2, nType: 2, cTitle: "Reset Form Warning"}); if (nResponse == 4) { this.resetForm(); } and click 'OK'.

5
Test the Reset Button

Close the form editing mode and click your button. A dialog box should appear, allowing you to proceed with 'OK' or abort with 'Cancel'.

Add a JavaScript Action to the Reset Button
Prevent Data Loss: This confirmation step ensures that users do not accidentally wipe out their hard work by misclicking the reset button.
Edit PDF Forms Easily

Manage and Fill PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to effortlessly manage, fill, and sign interactive PDF forms without needing complex configurations.

  1. 1. Open WPS Office: Launch WPS Office and click on the 'PDF' tab on the home screen.
  2. 2. Load Your PDF Form: Click 'Open' and select the interactive PDF form you want to fill or edit.
  3. 3. Fill or Edit the Form: Use the tools provided in the PDF viewer to input text, check boxes, or interact with buttons seamlessly.
  4. 4. Save and Share: Once completed, click 'Save' to preserve your form data, or use the share options to send the document directly.
Easily fill and navigate interactive PDF formsFully compatible with Adobe Acrobat PDF formatsLightweight and free alternative for standard PDF editing tasksBuilt-in electronic signature capabilities
microsoft office alternative - wps office

Frequently Asked Questions

Can I customize the warning message in the JavaScript dialog?

Yes, you can modify the text inside the cMsg parameter of the app.alert function to display your own custom warning, such as 'Do you really want to delete your progress?'.

What happens if the user clicks Cancel or presses Escape?

The JavaScript condition checks the user's response. If Cancel or Escape is pressed, the script simply terminates without executing the this.resetForm() command, leaving all form data completely intact.

Does this JavaScript warning work in all PDF viewers?

While it works perfectly in full-featured PDF software like Adobe Acrobat and WPS Office, some basic built-in web browser PDF viewers might not fully support interactive JavaScript actions.