How to Display Text Labels Instead of Numeric Codes in PDF Forms
Question details
The user needs a PDF form template to automatically convert and display descriptive text labels when raw numeric item codes are inputted or received.

- Product
- Device & OS
- not provided
- Scenario
- A PDF form template is designed to receive numeric item codes (like 000 or 001) from users or other applications, but needs to output a human-readable text label.
- Observed behavior
- The form field currently displays the raw numeric code natively rather than interpreting it and rendering the desired corresponding text label.
Ensure you are using a PDF editing application that supports JavaScript form field validation and verify exactly which item codes need to be mapped to which labels.
Add a JavaScript Validation Script to the Form Field
This is the most direct method to alter the displayed value upon input, using a simple validation script to prefix or replace the numeric code.
By applying a custom JavaScript validation rule directly to the item field, you can intercept the numerical input and instantly modify the text that appears on the screen before the user moves to the next field.
Open your PDF form in edit mode, right-click the specific item field you want to modify, and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Validate' tab to view the data validation options for that specific field.
Select 'Run custom validation script' and click the 'Edit' button. Enter the script: event.value = "Label" + event.value; (replacing "Label" with your desired text), then click 'OK' to save.
Exit form editing mode and type a numeric code like '000' into the field. Press Enter or click away to confirm the text changes to 'Label000'.

Use a Document-Level Calculation Script
Use this method if the numeric value is assigned or refreshed by another field or an external application, requiring broader document-level processing.
Edit and Manage PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to create, edit, and manage interactive PDF forms effortlessly. Adjusting form properties, filling out templates, and managing standard PDF data is intuitive and seamless.
- 1. Open PDF in WPS: Launch WPS Office and open your target PDF form document.
- 2. Access Form Tools: Navigate to the 'Form' tab in the top ribbon to access editing options.
- 3. Edit Field Properties: Double-click any form field to open its properties and adjust formatting, values, or validation rules as needed.

Frequently Asked Questions
Why is my PDF form validation script not running?
JavaScript may be disabled in your PDF reader's security settings. Go to the application preferences, look for 'JavaScript' settings, and ensure that 'Enable Acrobat JavaScript' or the equivalent option is turned on.
Can I use entirely different labels for specific numeric codes instead of just a prefix?
Yes. Instead of a simple concatenation script, you can write an 'if/else' or 'switch' statement in your JavaScript validation to map specific codes to entirely different text labels (e.g., if code is '001', event.value = 'Apples').
Will these scripts work if I print the PDF?
Yes. Once the script runs and updates the field's displayed value, the resulting text label will be visible on the digital form and will appear exactly as displayed when the document is sent to a printer.




