PDF Editing Issues

How to Set Acrobat JavaScript Validation for Values Between 100 and 400,000

Camila MilosovichCamila Milosovich Nov 10, 2026 869 views

Question details

The user needs a mathematical validation method for a PDF form field so that it only accepts values between 100 and 400,000 that are exact multiples of 100.

How to Set Acrobat JavaScript Validation for Values Between 100 and 400,000
Product
PDF Form
Device & OS
not provided
Scenario
Creating custom validation rules for fillable PDF form fields to restrict user numeric input dynamically without listing every single valid number.
Observed behavior
A mathematical validation method using JavaScript is required to validate specific value ranges and multiples.
Before you start

Ensure you are using a PDF editor that supports form field creation and JavaScript execution, and verify that your target text field is designated for numeric input.

Solution 1Recommended

Use the Modulo Operator in a Custom Validation Script

Apply a custom JavaScript validation script to the form field to dynamically check if the entered number falls within the required range and is a multiple of 100.

Instead of manually defining thousands of valid entries, you can utilize JavaScript's modulo operator (%). The modulo operator calculates the remainder of a division operation, allowing you to easily verify if an entered number is an exact multiple of 100.

1
Open Field Properties

Open your PDF form in edit mode, right-click the target text field, and select 'Properties' from the context menu.

2
Navigate to the Validate Tab

In the Text Field Properties dialog box, click on the 'Validate' tab to set up input restrictions.

3
Enable Custom Scripting

Select the 'Run custom validation script' option and click the 'Edit' button to open the JavaScript editor.

4
Enter the Validation Code

Type the following script: `if (event.value) { var v = Number(event.value); if (v < 100 || v > 400000 || v % 100 != 0) { app.alert("The entered value must be at least 100 and a multiple of 100."); event.target.textColor = color.red; } else { event.target.textColor = color.black; } }`

5
Save and Test

Click 'OK' to save the script, close the properties window, and exit edit mode to test the form field with various numbers.

Use the Modulo Operator in a Custom Validation Script
Understanding the Script: The statement `v % 100 != 0` checks if the number is not a multiple of 100. If the condition is met, it triggers a warning alert and changes the input text color to red. Valid entries automatically reset the text color to black.
Edit PDF Forms Easily

Manage and Fill PDF Forms with WPS Office

WPS Office provides comprehensive PDF tools to read, edit, and fill interactive PDF forms smoothly. It handles complex form validations seamlessly and serves as a powerful, lightweight alternative for your daily document tasks.

  1. 1. Open Your PDF: Launch WPS Office and open the PDF document containing the interactive forms.
  2. 2. Access Form Tools: Navigate to the 'Form' or 'Fill & Sign' tab to access tools specifically designed for interactive documents.
  3. 3. Fill the Data: Click on the designated fields and enter your data; any embedded JavaScript validations will execute automatically.
  4. 4. Save the Document: Once completed, click 'Save' to preserve your inputs or export the filled form to share with others.
Interacts flawlessly with PDF forms containing custom JavaScript validations.Fully compatible with standard PDF files and Microsoft Office formats (Word, Excel, PowerPoint).Lightweight software with an intuitive, user-friendly interface.Allows easy editing of text, images, and pages within PDFs across multiple platforms.
microsoft office alternative - wps office

Frequently Asked Questions

What does the modulo operator (%) do in JavaScript validation?

The modulo operator returns the remainder of a division operation. In form validation, checking if a value modulo 100 equals zero ensures the entered number is an exact mathematical multiple of 100.

Why does my custom validation script not trigger when I type?

Ensure that the script is placed under the 'Validate' tab of the field properties, rather than the 'Calculate' or 'Format' tabs. Validation scripts only trigger when the user commits the data by clicking outside the field or pressing Enter.

How do I revert the text color to normal after an invalid entry?

The provided script handles this automatically using the `else` block: `event.target.textColor = color.black;`. This line resets the text color to black as soon as a valid number is entered into the field.

Can I use this script for different number ranges?

Yes, you can easily customize the script by modifying the variables in the `if` statement. Simply change the `< 100` and `> 400000` values to match your specific minimum and maximum limits.