How to Create If-Then Validation Rules in Acrobat PDF Forms
Question details
The user needs to implement conditional logic in a fillable PDF uniform order form, where a size dropdown becomes a required field only if a user inputs a quantity for that specific item.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up a fillable uniform order form with multiple item categories (shirts, pants, ties, shoes) that requires conditional data entry to prevent incomplete orders.
- Observed behavior
- The user wants to enforce a rule preventing form submission unless the corresponding size field is selected when a quantity greater than zero is entered.
Ensure you have Adobe Acrobat Pro installed, as standard PDF readers do not support creating or editing form-level JavaScript. You should also compile a list of the exact field names used in your form before writing the validation script.
Use Document-Level JavaScript for Form Validation
Implementing custom JavaScript on the submit button or at the document level is the most effective way to validate multiple conditional fields before a user can submit the form.
Standard PDF form properties do not support 'if-then' conditional requirements. By using Acrobat JavaScript, you can programmatically check whether a quantity field has a value greater than zero. If it does, the script checks if the corresponding size dropdown is filled. If the size is missing, the script alerts the user and halts the submission process.
Launch Adobe Acrobat Pro, open your PDF form, and navigate to the 'Prepare Form' tool from the right-hand pane.
Double-click your quantity and size fields to open their Properties. Ensure they have distinct, logical names (e.g., 'ShirtQty' and 'ShirtSize').
Right-click your 'Submit' button, select 'Properties', and navigate to the 'Actions' tab. Delete any default 'Submit a form' action.
Under 'Select Action', choose 'Run a JavaScript' and click 'Add'. This will open the JavaScript editor window.
Enter an if-then statement checking the fields. For example: `if (this.getField('ShirtQty').value > 0 && this.getField('ShirtSize').value == '') { app.alert('Please select a shirt size.'); } else { this.submitForm({ cURL: 'mailto:your@email.com' }); }`.
Click 'OK', close the Prepare Form mode, and test entering a quantity without a size to ensure the error prompt appears.

View, Fill, and Manage PDF Forms with WPS Office
While creating advanced JavaScript validation requires specialized Adobe software, WPS Office provides a robust, lightweight PDF editor that allows you to seamlessly open, fill, and manage interactive PDF forms on any device.
- 1. Launch WPS PDF: Open WPS Office on your computer and select the 'PDF' tab to access the built-in PDF tools.
- 2. Open your PDF form: Click 'Open' and select your fillable uniform order form from your local directories.
- 3. Fill the form fields: Click directly on the text boxes, dropdowns, or checkboxes to input your order details and quantities.
- 4. Save and submit: Once filled, click 'Save' to retain your inputted data, then easily share or email the completed PDF form.

Frequently Asked Questions
Can I set conditional required fields in a PDF without using JavaScript?
No, standard PDF form properties do not natively support conditional logic (such as 'if X is filled, then Y becomes required'). You must use Acrobat JavaScript to dynamically validate the fields based on user input.
Why isn't my PDF submit button validating the conditional fields?
If your Submit button uses the standard 'Submit a form' action, it will only check fields explicitly marked as 'Required' in the field properties. To run conditional validation, you must change the button's action to 'Run a JavaScript' and trigger your custom validation script before allowing the submission.
How do I highlight incomplete required fields in my PDF form?
Inside your JavaScript validation script, you can change the appearance of empty required fields by modifying their fill color property. For example, using `this.getField('ShirtSize').fillColor = color.red;` will highlight the missed dropdown in red to alert the user.
Will JavaScript validation work if the user fills the form in a web browser?
Many built-in browser PDF viewers (like those in Google Chrome or Microsoft Edge) have limited or no support for Acrobat JavaScript. For form validation scripts to run reliably, users should be instructed to download the PDF and open it in a dedicated PDF application.




