How to Automatically Check PDF Checkboxes Based on a Number Range
Question details
The user wants to automate a PDF form so that specific checkboxes are automatically selected when a number falling within a defined range is entered into a text field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Automating interactive PDF form validation and data entry based on user-provided numeric values.
- Observed behavior
- The PDF form requires a custom validation script applied to a numeric text field to dynamically check appropriate boxes when the user enters a number.
Ensure you have a PDF editor that supports JavaScript form formatting and that you have already created and uniquely named the required text field and checkboxes in your document.
Add a Custom Validation Script to the Text Field
Use a simple JavaScript code snippet in the text field's properties to evaluate the entered number and trigger the corresponding checkbox automatically.
By applying a custom script to the numeric text field, you can set conditional logic that automatically selects specific checkboxes when the entered value meets your exact criteria.
Open your PDF form in edit mode. Right-click the numeric text field where users will enter the number, and select 'Properties' from the context menu.
In the Text Field Properties dialog, click on the 'Validate' tab. Choose the option labeled 'Run custom validation script' and click the 'Edit' button.
Input the validation script. For example: `var v = Number(event.value); this.getField("Checkbox1").checkThisBox(0, v >= 200 && v <= 500);`. Replace "Checkbox1" with your exact checkbox name and update the number ranges according to your needs.
Click 'OK' to close the editor, then click 'Close' on the Properties window. Save your PDF and test the form by typing a number within the range to see if the checkbox checks automatically.

Easily Build and Automate PDF Forms with WPS Office
WPS Office provides robust PDF editing capabilities, allowing you to insert interactive form fields like text boxes and checkboxes, and apply basic logic to streamline data collection.
- 1. Open the PDF File: Launch WPS Office and open your existing PDF document.
- 2. Access Form Controls: Navigate to the 'Form' tab on the top ribbon to access the interactive field tools.
- 3. Add and Configure Fields: Click 'Text Field' or 'Check Box' to add them to your page. Double-click the field to edit properties and manage interactivity.
- 4. Save the Form: Once your fields are set up, save the document to lock in the form features.

Frequently Asked Questions
Can I set up multiple conditions for different checkboxes?
Yes. You can expand the JavaScript by adding more lines to evaluate different ranges. For example, add `this.getField("Checkbox2").checkThisBox(0, v > 500 && v <= 1000);` directly below your first line of code.
Why isn't my checkbox updating immediately as I type?
PDF validation scripts are usually triggered by an 'On Blur' event, meaning the field must lose focus first. The user needs to press 'Enter', 'Tab', or click anywhere outside the text field for the script to run and check the box.
Do I need advanced programming knowledge to automate checkboxes?
No. Basic JavaScript logic is enough. You can copy the provided snippet and simply swap out the target field name (e.g., "Checkbox1") and the logical operators (e.g., >= 200) to fit your specific form layout.
Will these automated checkboxes work on mobile PDF viewers?
JavaScript support varies widely among mobile PDF apps. While it works reliably on desktop applications like WPS Office and Adobe Acrobat, mobile viewers might not process the custom validation scripts properly.




