How to Require One Complete Row in PDF Forms with Acrobat JavaScript
Question details
The user needs to validate a PDF form using JavaScript to ensure that at least one out of three rows (groups of fields) is fully completed before allowing the form submission.

- Product
- Adobe Acrobat PDF Forms
- Device & OS
- not provided
- Scenario
- Setting up custom JavaScript validation rules on a PDF form with multiple rows of fields to enforce logical completion requirements.
- Observed behavior
- The user wants the form to display a validation alert only when all three rows are incomplete, correctly identifying which specific category the user should fill.
Ensure you have your PDF form open in editing mode with all field names properly defined (e.g., T1, M1, B1) so the JavaScript variables can reference them correctly.
Implement Outer and Inner Conditional Logic in Form Validation
Use JavaScript to check if every row is incomplete first, then trigger specific alerts based on which row the user should target.
The most efficient way to validate this requirement is by using a combined conditional statement that evaluates all rows simultaneously. If all rows are missing data, the script steps into a secondary block to alert the user exactly which category needs attention.
Open your PDF document in form editing mode, right-click the 'Submit' button, select 'Properties', and navigate to the 'Actions' tab.
Choose 'Run a JavaScript' from the 'Select Action' dropdown menu, then click the 'Add' button to open the script editor.
Enter the validation script using an outer condition to check if all rows are incomplete: `if ((T1=="" || M1=="" || B1=="") && (T2=="" || M2=="" || B2=="") && (T3=="" || M3=="" || B3=="")) { ... }`
Inside the brackets, add the inner condition to display the appropriate alert: `if (T1=="" || M1=="" || B1=="") app.alert("Fill Category 1"); else if (T2=="" || M2=="" || B2=="") app.alert("Fill Category 2"); else app.alert("Fill Category 3");`
Click 'OK' to save the script, exit form editing mode, and test the form by leaving all fields blank to ensure the alert appears correctly.

Manage and Edit PDF Forms Seamlessly with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to easily view, fill, and manage interactive PDF forms. Whether you need to input data, add signatures, or convert forms to other formats, WPS PDF offers a smooth and efficient experience.
- 1. Install WPS Office: Download and install the free version of WPS Office on your device.
- 2. Open the form: Launch WPS PDF and open your interactive PDF form.
- 3. Fill out the fields: Click directly on the interactive fields, checkboxes, or dropdowns to input your data.
- 4. Save or export: Once complete, save your form or export it securely for sharing.

Frequently Asked Questions
Why is my PDF JavaScript alert not triggering?
This typically happens if the field names referenced in your script do not exactly match the field names defined in the PDF form, or if JavaScript execution is disabled in your PDF viewer's preferences.
Can I use this validation script directly on a submit button?
Yes, you can attach this script to the 'Mouse Up' trigger of a Submit button. This ensures the validation logic runs right before the user attempts to send or save the form data.
How do I prevent the form from submitting if the alert is triggered?
To prevent submission, you can add an event cancellation to your script (e.g., `event.rc = false;`) immediately after the `app.alert` lines. This stops the subsequent submit action from executing.




