How to Ignore Hidden Required Fields in Acrobat JavaScript Validation
Question details
The user needs a method to validate required PDF form fields while specifically excluding fields that are currently hidden.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Validating required fields upon PDF form submission or completion.
- Observed behavior
- Currently, the JavaScript validation checks all required fields, including hidden ones, potentially preventing form submission if hidden fields are left empty.
Ensure you have access to the PDF form's source script and basic knowledge of JavaScript syntax to modify form field properties safely.
Update the JavaScript Validation Condition
Modify your existing JavaScript code to explicitly check the display state of the field, ensuring the validation skips any field that is hidden.
Standard validation scripts often loop through all fields and check if they are required and empty. By default, this includes hidden fields.
To bypass hidden fields, you must add an explicit check for the `display` property within your `if` condition using the `display.hidden` constant.
Open your PDF file, navigate to the Prepare Form tool, and locate the button or document-level script that triggers the validation.
Find the `for` loop in your script that iterates through the form fields (typically defining a variable like `f` for the current field).
Modify the conditional statement to include `f.display !== display.hidden`. For example, change your validation line to: `if (tt.indexOf('*') != -1 && f.value == f.defaultValue && f.display !== display.hidden)`.
Apply the changes, close the script editor, and save the PDF. Test the form by leaving a hidden required field blank and verifying that the validation now successfully passes.

Manage Interactive PDF Forms Easily with WPS Office
WPS Office provides a highly compatible PDF editor that allows you to seamlessly fill, manage, and edit interactive PDF forms without getting bogged down by complex script errors.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Navigate to the Form tools: Switch to the 'Form' or 'Fill & Sign' tab on the top ribbon to access the interactive fields.
- 3. Fill and Save: Easily interact with checkboxes, text fields, and dropdowns, then save or export your finalized document.

Frequently Asked Questions
Why does my PDF form fail to submit when hidden fields are empty?
Standard JavaScript validation scripts loop through all fields marked as required. Because the script does not inherently care about visual layout, empty required hidden fields will trigger a validation error unless explicitly told to ignore them.
What does `display.hidden` mean in Acrobat JavaScript?
`display.hidden` is a built-in constant in PDF JavaScript that refers to the state where a field is not visible on the page and does not print. Its numerical value is typically 1.
Can I dynamically make a field visible again using JavaScript?
Yes, you can change a field's display property back to visible dynamically based on user actions by executing the script `f.display = display.visible;`.




