PDF Editing Issues

How to Validate Required Fields When Saving a PDF in Acrobat

Tauseeq MagsiTauseeq Magsi Oct 28, 2026 869 views

Question details

The user wants to trigger a JavaScript validation for required form fields automatically when selecting File > Save or Save As in Adobe Acrobat.

How to Validate Required Fields When Saving a PDF in Acrobat
Product
Adobe Acrobat 2017
Device & OS
not provided
Scenario
Creating interactive PDF forms with required fields that need validation before the user saves the document.
Observed behavior
JavaScript validation works via a custom button, but the user is looking for a way to intercept the standard File > Save command.
Before you start

Ensure you have access to the Prepare Form tool in your PDF software and that your form fields are properly named and marked as required.

Solution 1Recommended

Create a Custom Validate and Save Button

Since Acrobat cannot reliably intercept and cancel the standard Save command, the best practice is to create a custom button that runs the validation script and then executes the save action.

Adobe Acrobat does not provide a document event that can abort the standard File > Save action if a script fails. To enforce validation, you must route users through a custom form button.

1
Add a Button to the Form

Open the Prepare Form tool in Acrobat and add a new Button field to your document. Place it prominently at the bottom of the form.

2
Set Button Properties

Right-click the new button, select Properties, and navigate to the Actions tab.

3
Add JavaScript Action

Choose 'Run a JavaScript' from the Select Action dropdown and click the Add button.

4
Enter Validation Code

Input your JavaScript code that checks the required fields. If the validation passes, add the command app.execMenuItem('Save'); or app.execMenuItem('SaveAs'); at the end of the script to trigger the save dialog.

Create a Custom Validate and Save Button
User Instructions: Consider adding a text note to your form instructing users to use your custom 'Save Form' button instead of the standard Acrobat menu.

Create and Manage PDF Forms Easily with WPS Office

WPS Office provides an intuitive PDF editor that allows you to create interactive forms, set required fields, and fill them out seamlessly without complex JavaScript coding.

  1. 1. Open WPS PDF: Launch WPS Office and open your PDF document.
  2. 2. Access Form Tools: Navigate to the Form tab on the top ribbon to access the form creation and editing tools.
  3. 3. Add and Configure Fields: Insert text fields or buttons into your document. Double-click any field to modify its properties, such as setting it as a required field.
  4. 4. Save and Share: Once your form is complete, click the Save icon in the top left corner to save your interactive PDF securely.
Easily add text fields, checkboxes, and form buttons to your PDF.Highlight required fields so users instantly know what to fill out.Fully compatible with standard Adobe PDF form formats.Lightweight, fast, and available across Windows, Mac, and mobile.
microsoft office alternative - wps office

Frequently Asked Questions

Can I stop a PDF from saving if required fields are empty in Acrobat?

No, Adobe Acrobat does not provide a built-in event that can intercept and cancel the File > Save command. You must use a custom JavaScript button to run the validation before executing the save action.

What is the Document Will Save event used for?

The 'Document Will Save' event triggers right before a document is saved. It is primarily used for updating timestamps, flattening fields, or calculating hidden values, but it cannot be used to abort the save process.

How do I make a form field required in a PDF?

In form editing mode, right-click the specific field, select Properties, and check the 'Required' box. This visually highlights the field for the user but does not strictly prevent them from saving the file if left blank.

Can JavaScript force a 'Save As' dialog in a PDF?

Yes, you can use app.execMenuItem('SaveAs'); within a custom button script. This prompts the user to save the document under a new name after your validation logic has run successfully.