How to Automatically Format Numbers in an Acrobat PDF Text Field
Question details
The user needs to automatically format a raw 14-digit input number into a specific punctuated pattern (e.g., 22.222.355/0001-09) within a PDF form text field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form where specific numeric inputs, such as business registration numbers or tax IDs, require strict structural formatting.
- Observed behavior
- The text field accepts raw numbers but does not automatically apply the required punctuation and spacing without custom formatting rules.
Ensure you have Adobe Acrobat Pro installed, as standard free PDF readers do not support editing form fields or adding custom JavaScript formatting scripts.
Apply Custom Formatting Using Acrobat JavaScript
Use the built-in Acrobat JavaScript function util.printx() to force a 14-digit number into your desired format automatically after the user enters it.
This method requires writing a brief custom formatting script in the field's properties. The util.printx() function applies a specific pattern to the input string, provided the input always contains the exact same number of digits (in this case, 14 digits).
Open your PDF in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form'.
Right-click the target text field where users will enter the number and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Format' tab. From the 'Select format category' dropdown, choose 'Custom'.
In the 'Custom Format Script' box, enter the following code: if (event.value) { event.value = util.printx("99.999.999/9999-99", event.value); }
Click 'Close' to save the properties. Click 'Preview' at the top right to test the field by typing a 14-digit number like 22223555000109.

Easily Manage and Edit PDF Forms with WPS Office
While complex JavaScript formatting requires specialized software, WPS Office provides a highly intuitive PDF editor to easily create, fill, and manage interactive PDF forms for your daily document workflows.
- 1. Open PDF in WPS Office: Launch WPS Office and open your PDF file using the PDF tab.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view available form creation and editing tools.
- 3. Add or Edit Fields: Select 'Text Field' to add new input areas, or click on existing fields to modify their properties directly.
- 4. Save and Export: Once your form is complete, save the document to ensure all interactive fields are preserved.

Frequently Asked Questions
Do I have to use programming to format numbers in a PDF text field?
For complex, non-standard formats like '22.222.355/0001-09', custom JavaScript is currently the only robust method in Acrobat. Built-in formatting options only cover standard dates, times, percentages, and basic zip codes.
What happens if a user enters fewer than 14 digits?
If the input is shorter than the placeholders in the util.printx() function, the formatting may misalign or fail to apply correctly. It is recommended to add a custom validation script to ensure exactly 14 digits are entered before the format is applied.
Can I use this JavaScript format in free PDF readers?
Yes. While you need a Pro PDF editor to add the JavaScript formatting rule to the form field initially, standard free PDF readers will successfully execute the script and format the number when a user subsequently fills out the form.




