Make Acrobat Form Fields Required When a Value Exceeds 1
Question details
Make several PDF form fields required when a controlling field contains a value greater than 1.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form uses an Adult text field to determine whether other fields must be completed.
- Observed behavior
- When the Adult value exceeds 1, the specified fields should become required; otherwise, they should remain optional.
Open the PDF in a version of Adobe Acrobat that can edit form fields, and identify the exact names of the controlling and dependent fields. The PDF viewer used to fill out the form must support Acrobat form JavaScript.
Add a validation script to the controlling field in Acrobat
Use a custom validation script to switch several fields between required and optional based on the Adult field value.
In Acrobat, open the PDF and select All tools > Prepare a form, or Tools > Prepare Form in older versions.
Double-click the Adult text field, select the Validate tab, and choose Run custom validation script. Click Edit.
In the JavaScript editor, enter: var fields = ["field1", "field2", "field3", "field4", "field5"]; for (var i = 0; i < fields.length; i++) { this.getField(fields[i]).required = Number(event.value) > 1; } Replace each sample name with the exact name of a dependent form field, and add or remove names as needed.
Click OK, close the field properties, and save the PDF. Enter a value greater than 1 in Adult and leave the field to commit the value; then test with 1 or less. If the form has a submit button, test submission with dependent fields left empty.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative for working with PDFs and familiar Office documents. Its familiar interface and format support make moving everyday files straightforward; use Acrobat for the conditional form-field script described above.

Frequently Asked Questions
Where do I find the names of the fields to use in the script?
In Acrobat, open Prepare a form and double-click each dependent field. Check its name in the field properties and use that exact name in the fields array.
What happens when the Adult value changes back to 1?
After the value is committed, the validation script sets the listed fields' Required property to false because the value is not greater than 1.
Why does the form still save with required fields empty?
The Required property is generally enforced during form submission, not when the PDF is saved. Test with the form's submit button if one is configured.
Will the script work in every PDF viewer?
No. The viewer must support the relevant Acrobat form JavaScript. Test the form in the viewer that recipients will use.




