How to Validate Numbers or Text in Acrobat PDF Form Fields
Question details
The user needs to configure a PDF form field to accept either whole numbers with comma separators or specific text abbreviations (such as TBD or BTS).

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where a specific field requires a mixed-type data entry of either formatted numeric values or predetermined text strings.
- Observed behavior
- Standard number formatting natively restricts the input to numbers only, automatically rejecting necessary text values like 'TBD' or 'BTS'.
Ensure you have access to the PDF form editing tools and JavaScript console in your PDF editor before attempting to apply custom validation scripts.
Use a Custom JavaScript Validation Script
A custom validation script allows you to define exactly which data formats (numbers or specific strings) are acceptable, overriding default restrictions.
Because standard PDF number formatting does not allow text input, you must use a custom validation script. By applying a Regular Expression (Regex), you can program the field to accept either a whole number with comma separators or specific text abbreviations, rejecting all other unexpected input.
Open your PDF in Acrobat, go to the 'Tools' menu, and select 'Prepare Form' to enable form editing.
Right-click the target form field and select 'Properties' from the context menu.
Navigate to the 'Validate' tab, select the option 'Run custom validation script', and click the 'Edit' button.
Paste the following script into the editor: event.rc = /^(?:\d{1,3}(?:,\d{3})*|TBD|BTS)$/.test(event.valueAsString); then click 'OK'.
Close the properties window, exit form editing mode, and test the field by typing a formatted number or 'TBD'.

Apply a Custom Keystroke Script
Use a keystroke script to prevent users from typing invalid characters into the field entirely.
Create and Validate PDF Forms with WPS Office
WPS Office provides a comprehensive suite of PDF tools, allowing you to easily create interactive forms, add text fields, and configure data validation without complex setups.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to access interactive form features.
- 3. Insert a Text Field: Select 'Text Field' and click anywhere on your document to place the field.
- 4. Configure properties: Double-click the newly created field to open its Properties dialog and configure your validation rules.

Frequently Asked Questions
Why does my PDF form field reject text when set to a number format?
When a field is formatted as a number in PDF form properties, the software automatically applies a built-in validation rule that strictly rejects any non-numeric characters, preventing the input of text like 'TBD'.
What is the difference between a validation script and a keystroke script?
A validation script checks the entire value after the user finishes typing and attempts to leave the field. A keystroke script evaluates each character immediately as it is typed, blocking invalid keys instantly.
Can I automatically add commas to numbers without using JavaScript?
Yes, standard number formatting allows for automatic comma separators. However, if you also need the same field to accept specific text options, default settings cannot be used, and you must rely on custom format and validation scripts instead.
Does WPS Office support editing PDF form fields?
Yes, WPS Office offers robust PDF tools that allow users to create, edit, fill, and manage interactive PDF forms effortlessly.




