How to Create Unique Number Fields in Adobe Acrobat Forms
Question details
The user needs to create a row of five text boxes in a PDF form that only accept unique numbers from 1 to 5, preventing duplicate values across the fields.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form that requires users to rank items or input unique values from 1 to 5 without repeating numbers.
- Observed behavior
- The user needs a method to implement custom form-field validation to restrict entries to integers 1-5 and display an error if a duplicate number is entered in another field.
Ensure you have access to Adobe Acrobat Pro, as the free Adobe Reader does not support creating form fields or adding custom JavaScript validation logic.
Implement Custom JavaScript Validation for PDF Form Fields
Use Adobe Acrobat's custom JavaScript calculation and validation scripts to restrict inputs to numbers 1-5 and dynamically prevent duplicate entries.
This method requires adding a custom validation script to each of the five text fields. When a user inputs a number, the script will check the values of the other fields and reject the input if it already exists, ensuring all five fields remain unique.
Open your PDF in Adobe Acrobat Pro, navigate to the 'Prepare Form' tool, and add five text fields in a row. Name them logically for easy scripting, such as Field1, Field2, Field3, Field4, and Field5.
Right-click the first field, select 'Properties', and go to the 'Format' tab. Set the format category to 'Number' with zero decimal places to ensure only integers are accepted.
Switch to the 'Validate' tab in the Properties window. Select 'Value is the range from', and enter 1 for the minimum and 5 for the maximum.
Change the validation to 'Run custom validation script' and click 'Edit'. Enter a JavaScript loop that compares 'event.value' with the values of the other four fields. If a match is found, use 'app.alert()' to notify the user and set 'event.rc = false' to reject the input.
Apply the same JavaScript logic to the remaining four fields, updating the script in each field so it checks against the correct corresponding text boxes.

Create and Edit PDF Forms Seamlessly with WPS Office
While complex cross-field validation requires specialized scripting in Acrobat, WPS Office offers an intuitive, user-friendly PDF editor to quickly create, fill, and manage interactive PDF forms for your daily workflow.
- 1. Open WPS PDF Editor: Launch WPS Office and open your PDF document using the built-in WPS PDF tool.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form controls.
- 3. Insert Form Fields: Click on 'Text Field' and click anywhere on the document page to place it. Double-click the field to customize its name, size, and properties.
- 4. Save and Distribute: Once your fields are placed, click 'Save'. The resulting interactive PDF form will be perfectly compatible with any standard PDF viewer.

Frequently Asked Questions
Can I use the free Adobe Reader to add JavaScript validation?
No, Adobe Reader only allows users to view PDFs and fill out existing forms. To create form fields and apply custom JavaScript validation, you must use a premium editor like Adobe Acrobat Pro.
What happens if a user enters a duplicate number in the PDF form?
If the custom JavaScript validation is set up correctly, the form will reject the duplicate input, display a warning pop-up message to the user, and clear the field so they can enter a valid number.
Can I prevent duplicate entries without writing JavaScript code?
Adobe Acrobat's built-in, no-code validation options only allow for simple numerical range checks (like accepting numbers 1-5). Comparing values across multiple different fields to check for duplicates strictly requires custom JavaScript.
Are JavaScript-validated PDF forms fully compatible with mobile devices?
Support for custom JavaScript in PDF forms is highly limited on mobile devices. Many third-party mobile PDF readers ignore complex validation scripts, meaning users might still bypass the duplicate check on smartphones.




