How to Validate Required Fields When Saving a PDF in Acrobat
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.

- 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.
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.
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.
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.
Right-click the new button, select Properties, and navigate to the Actions tab.
Choose 'Run a JavaScript' from the Select Action dropdown and click the Add button.
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.

Utilize the Document 'Will Save' Event
You can add a script to the Document Will Save event to warn users about missing fields, though it cannot cancel the save action.
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. Open WPS PDF: Launch WPS Office and open your PDF document.
- 2. Access Form Tools: Navigate to the Form tab on the top ribbon to access the form creation and editing tools.
- 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. Save and Share: Once your form is complete, click the Save icon in the top left corner to save your interactive PDF securely.

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.




