PDF Editing Issues

How to Show a Save Warning Before Clearing an Acrobat PDF Form

Aamir Naveed AkramAamir Naveed Akram Nov 5, 2026 870 views

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.

How to Show a Save Warning Before Clearing an Acrobat PDF Form
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.
Before you start

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.

Solution 1Recommended

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.

1
Access Button Properties

In Adobe Acrobat, open the 'Prepare Form' tool. Right-click your Clear Form button and select 'Properties'.

2
Remove Existing Actions

Navigate to the 'Actions' tab. Select and delete any existing chained actions like 'Execute a menu item' or 'Reset a form' to avoid conflicts.

3
Add Custom JavaScript

Under 'Select Action', choose 'Run a JavaScript' from the dropdown menu and click the 'Add' button.

4
Enter the Code

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'.

5
Save and Test

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.

Use Conditional JavaScript for the Clear Form Button
JavaScript Support Across Readers: The custom JavaScript relies on Adobe Acrobat's specific API. Users opening the PDF in basic web browsers or third-party readers that do not support Acrobat JavaScript may not experience the intended behavior.

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. 1. Open PDF in WPS: Launch WPS Office and open your fillable PDF form.
  2. 2. Fill the Form: Use the intuitive PDF tools to type your responses directly into the form fields.
  3. 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.
Complete PDF editing and interactive form-filling capabilities.Highly compatible with standard Adobe Acrobat PDF forms.Free and lightweight alternative to heavy PDF software.Cross-platform support for Windows, Mac, iOS, and Android.
microsoft office alternative - wps office

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).