Validate Payment Amount Ranges Based on a Checkbox in Adobe Acrobat Forms
Question details
The user needs to apply conditional logic to validate payment amounts in a PDF form based on whether a specific payment method checkbox is selected.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form that requires different minimum and maximum payment ranges depending on the chosen payment method, such as Credit Card versus Personal Check.
- Observed behavior
- Validation alerts trigger incorrectly, displaying errors even when the payment amount field is empty or falls within the permitted numerical range for the selected payment method.
Ensure your PDF form has the correct, exact field names for both the payment method checkbox and the payment amount text field before applying the JavaScript code.
Correct the JavaScript Conditional Logic for Payment Validation
Fix the alert issue by placing the amount range comparison strictly inside the conditional statement to ensure alerts only run for invalid values associated with the active checkbox state.
The logic error occurs because the range constraints are evaluated independently of the checkbox state. By placing the boundary checks inside the if/else logic of the checkbox, you can ensure that the form correctly applies specific rules (e.g., limits for Personal Checks versus Credit Cards).
Open your PDF form in Adobe Acrobat, enter the Prepare Form mode, right-click the payment amount text field, select Properties, and navigate to the Validate tab.
Select the 'Run custom validation script' option and click the Edit button to open the JavaScript editor.
Enter the conditional script checking the checkbox value. For example: if (this.getField('Personal Check').valueAsString != 'Off') { if (event.value < 99 || event.value > 3598) { app.alert('Other payments cannot be less than $99 or more than $3,598'); } } else if (event.value < 99 || event.value > 1849) { app.alert('Credit card payments cannot be less than $99 or more than $1,849'); }
Click OK to close the editor and properties panel. Test the form by checking the boxes and entering valid, invalid, and empty values to verify that the alerts trigger accurately.

Create and Edit PDF Forms Seamlessly with WPS Office
If you are looking for a straightforward way to build and manage interactive PDF forms without dealing with complex JavaScript syntax, WPS Office provides an intuitive suite of PDF tools to add text fields, checkboxes, and buttons with ease.
- 1. Open your PDF: Launch WPS Office and click on the 'PDF Edit' tab to open your document.
- 2. Access Form Controls: Navigate to the 'Form' menu on the top ribbon to access interactive form controls.
- 3. Insert Form Fields: Select 'Check Box' or 'Text Field' and click on the desired location on the page to place the elements.
- 4. Customize and Save: Double-click the form field to customize its appearance and properties, then save your interactive PDF.

Frequently Asked Questions
Why does my PDF form validation alert trigger when the text field is completely empty?
By default, an empty field often evaluates to zero during JavaScript calculations in Acrobat. To prevent this, you should add an initial check (such as `if (event.value == '') return;`) at the very beginning of your validation script to safely ignore blank entries unless the field is strictly marked as required.
How do I check if a checkbox is selected in an Acrobat PDF form using JavaScript?
You can determine a checkbox's state by using the `valueAsString` property of that specific field. If the box is unchecked, it typically returns 'Off'. If checked, it returns its defined export value. For example: `this.getField('MyCheckbox').valueAsString != 'Off'`.
Can I use this conditional validation for multiple payment method checkboxes?
Yes. You can chain multiple `else if` statements to check the exported values of various checkboxes. This allows you to apply uniquely adjusted minimum and maximum threshold rules for each respective payment method.




