How to Get New Field Values in Acrobat JavaScript Validation Scripts
Question details
Developers need to retrieve the newly entered data in a PDF form field during validation, but custom scripts return the pre-modified value instead.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Writing and executing custom JavaScript validation scripts for interactive PDF form fields.
- Observed behavior
- Using getField().value inside the validation script retrieves the old, pre-modified value of the field rather than the newly entered data.
Ensure you have access to the PDF form's JavaScript editor in Prepare Form mode and basic familiarity with Adobe Acrobat's event model for form fields.
Use the event.value Property in the Validation Script
Access the newly entered value directly from the event object, which holds the uncommitted input before the validation process completes.
In Adobe Acrobat, a field's value is not officially committed to the document until the validation script runs and approves the input. Because of this, querying the field object directly via this.getField('FieldName').value will return the previous data.
To access the uncommitted, newly entered data being validated, you must use the event object provided by Acrobat's validation trigger.
Right-click the target form field in Acrobat's Prepare Form mode and select 'Properties'.
Click on the 'Validate' tab where your custom JavaScript validation script is configured.
Edit the script to replace instances of this.getField('YourFieldName').value with event.value to capture the new input.
Click 'Close' to save the properties, exit form editing mode, and type a new value into the field to verify the script processes the new data correctly.

Edit and Fill PDF Forms Seamlessly with WPS Office
WPS Office provides a powerful, built-in PDF editor that makes it easy to fill out interactive PDF forms, edit text, and manage your documents safely and efficiently.
- 1. Open WPS Office PDF: Launch WPS Office and click on the 'PDF' tab from the home screen to open the PDF module.
- 2. Load Your PDF Form: Click 'Open' and select your interactive PDF form document from your local storage.
- 3. Fill and Save: Click directly into the interactive form fields to enter your data. Once completed, click the 'Save' icon to retain your form entries securely.

Frequently Asked Questions
Why does getField().value return the old value in a keystroke script?
Similar to validation scripts, keystroke scripts run before the new data is fully committed to the field. You should use event.change to identify the specific character being typed, or event.value to evaluate the uncommitted state.
How can I automatically format a user's input during PDF validation?
If a user enters a value that requires formatting (such as capitalizing all text), you can assign the new formatted string directly to event.value within your custom validation script before it completes.
Does WPS Office support editing PDF forms created in Acrobat?
Yes, WPS Office fully supports opening, viewing, and filling interactive PDF forms created in Adobe Acrobat. It ensures high format compatibility for your daily PDF document processing needs.




