PDF Editing Issues

How to Create If-Then Validation Rules in Acrobat PDF Forms

Kushani NimanthikaKushani Nimanthika Oct 28, 2026 869 views

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.

Creating If-Then Validation Rules for Acrobat PDF Forms
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Prepare Form tool

Launch Adobe Acrobat Pro, open your PDF form, and navigate to the 'Prepare Form' tool from the right-hand pane.

2
Verify field names

Double-click your quantity and size fields to open their Properties. Ensure they have distinct, logical names (e.g., 'ShirtQty' and 'ShirtSize').

3
Edit the Submit button actions

Right-click your 'Submit' button, select 'Properties', and navigate to the 'Actions' tab. Delete any default 'Submit a form' action.

4
Add the JavaScript action

Under 'Select Action', choose 'Run a JavaScript' and click 'Add'. This will open the JavaScript editor window.

5
Write the validation script

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' }); }`.

6
Test the form

Click 'OK', close the Prepare Form mode, and test entering a quantity without a size to ensure the error prompt appears.

Use Document-Level JavaScript for Form Validation
Field Naming Convention: Consistent field naming is crucial. Use grouped names or identical prefixes to easily loop through multiple items like shirts, pants, and shoes in your script rather than writing separate rules for each item.
Manage PDF Forms Easily

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. 1. Launch WPS PDF: Open WPS Office on your computer and select the 'PDF' tab to access the built-in PDF tools.
  2. 2. Open your PDF form: Click 'Open' and select your fillable uniform order form from your local directories.
  3. 3. Fill the form fields: Click directly on the text boxes, dropdowns, or checkboxes to input your order details and quantities.
  4. 4. Save and submit: Once filled, click 'Save' to retain your inputted data, then easily share or email the completed PDF form.
Easily fill out and save interactive PDF forms with high reliabilityFully compatible with standard Adobe PDF formats and form fieldsLightweight PDF viewer and editor for quick, everyday document tasksCross-platform support to manage PDFs on Windows, Mac, and mobile
microsoft office alternative - wps office

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.