How to Show a Save Warning Before Clearing an Acrobat PDF Form
Question details
The user needs a way to prompt users with a save warning before a PDF form is cleared, ensuring the form doesn't reset if the user cancels the save action.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a fillable PDF form with a clear-form button to reset fields.
- Observed behavior
- When using default chained actions, the form still resets even if the user accidentally clicks the button and then cancels the Save As dialog.
Ensure your PDF form is fully created and that you have access to the Prepare Form tool in Adobe Acrobat to edit button properties and add custom JavaScript.
Use Conditional JavaScript for the Clear Form Button
Replace chained actions with a single JavaScript script that verifies the user's intent before executing the form reset, preventing accidental data deletion.
In Adobe Acrobat, simply chaining 'Save As' and 'Reset Form' actions together on a button causes both actions to run sequentially. This means the form will clear even if the user clicks Cancel in the Save dialog. Using a conditional JavaScript snippet fixes this issue.
In Adobe Acrobat, open the 'Prepare Form' tool. Right-click your Clear Form button and select 'Properties'.
Navigate to the 'Actions' tab. Select and delete any existing chained actions like 'Execute a menu item' or 'Reset a form' to avoid conflicts.
Under 'Select Action', choose 'Run a JavaScript' from the dropdown menu and click the 'Add' button.
Paste the following conditional code: if (app.alert("You should first save the file under a new name.", 3, 1) == 1) { app.execMenuItem("SaveAs"); this.resetForm(); } and click 'OK'.
Close the form editing mode, save your PDF, and test the button. The form will now only reset if the user confirms the prompt and completes the Save As dialog.

Fill and Manage PDF Forms Easily with WPS Office
WPS Office provides a powerful, built-in PDF editor that makes filling, saving, and managing PDF forms straightforward. You can easily save filled forms or safely clear them using its intuitive interface without relying on complex JavaScript coding.
- 1. Open PDF in WPS: Launch WPS Office and open your fillable PDF form.
- 2. Fill the Form: Use the intuitive PDF tools to type your responses directly into the form fields.
- 3. Save As: Click 'Menu' in the top-left corner and choose 'Save As' to keep a copy of your filled form before making further changes or clearing it.

Frequently Asked Questions
Why does my PDF form reset even if I click Cancel in the Save dialog?
If you use chained actions in Adobe Acrobat's button properties, the actions run sequentially regardless of the outcome of previous dialogs. The system continues to the 'Reset Form' command even if 'Save As' is canceled.
Can I recover a PDF form that was accidentally cleared?
If you have not saved or closed the document after clearing it, you can usually undo the action by pressing Ctrl+Z (Windows) or Cmd+Z (Mac). If the file was saved after clearing, the data cannot be recovered unless you have a previous backup.
What do the numbers '3' and '1' mean in the app.alert code?
In Acrobat JavaScript's app.alert method, the '3' specifies the icon type (a question mark icon), and the '1' specifies the button types (displaying OK and Cancel buttons).




