How to Add Number Formatting and Units to PDF Form Fields in Acrobat
Question details
The user needs to format a numeric value entered into a PDF form field to include standard number separators, decimal places, and a specific text unit suffix (e.g., displaying "8000" as "8,000.00 feet").

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form that requires physical measurements, dimensions, or custom currency displays.
- Observed behavior
- Standard PDF number formatting lacks built-in options for custom text suffixes, requiring a custom JavaScript solution to format the display while maintaining the numeric value for calculations.
Ensure you have the necessary permissions to edit the PDF form and that your target form field is set as a 'Text' field before applying custom JavaScript formatting.
Use a Custom Format Script with util.printf
Apply a JavaScript custom format script to automatically add commas, decimal places, and the required unit suffix to the entered number.
This is the most reliable method for appending text units to a number in a PDF form. It formats the visual display of the field while keeping the underlying value strictly numeric, ensuring that any subsequent calculations relying on this field continue to work correctly.
Open your PDF document 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.
Navigate to the 'Format' tab. In the 'Select Format Category' dropdown menu, choose 'Custom'.
In the 'Custom Format Script' box, click the 'Edit' button and paste the following code: `if ((event.value == "") || (event.value == 0)) event.value = ""; else event.value = util.printf("%,0.2f feet", event.value);`
Click 'OK' and then 'Close'. Exit the Prepare Form mode and test the field by typing a number like 8000 to verify it automatically formats to '8,000.00 feet'.

Use OnBlur and OnFocus Action Scripts
Use an OnBlur event to format the value when the user clicks away from the field, and an OnFocus event to clear it when they click back.
Create and Manage PDF Forms Seamlessly with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to effortlessly create, edit, and fill interactive PDF forms. Whether you need to manage text fields, adjust data formatting, or fill out complex forms, WPS PDF offers a highly compatible and intuitive experience without the steep learning curve.
- 1. Launch WPS PDF: Open WPS Office and click on the 'PDF' tab to launch the built-in PDF editor.
- 2. Open Your Form: Click 'Open' to load your existing interactive PDF form or use a blank document to start creating a new one.
- 3. Edit Form Fields: Navigate to the 'Form' tab on the top ribbon to insert new text fields, checkboxes, or dropdown menus.
- 4. Adjust Properties: Double-click any text field to access its properties, where you can modify appearance, alignment, and default text formatting.
- 5. Save and Export: Once your form is filled or configured, click 'Save' to ensure all data and formatting remain fully intact for sharing.

Frequently Asked Questions
Why isn't standard Acrobat number formatting enough for adding units?
Standard PDF number formatting typically only supports predefined currency symbols or percentage signs. It does not provide built-in options to append custom text strings like 'feet' or 'kg' to the end of a numeric value, which makes Custom Format Scripts necessary.
Will adding a text unit via JavaScript break my form calculations?
No, as long as you use a Custom Format Script. This type of script only alters the visual display (the formatted output) while keeping the underlying exported or calculated value strictly numeric. Using standard string concatenation without proper formatting events might break calculations.
How do I change the number of decimal places in the custom format script?
In the `util.printf` function, adjust the `%,0.2f` parameter. Change the `2` to `0` for no decimal places (e.g., `%,0.0f`), or to `3` for three decimal places (e.g., `%,0.3f`).
What happens if a user types text instead of a number into the field?
If the field is not restricted, the custom format script might return an unexpected result or 'NaN' (Not a Number). You can prevent this by navigating to the field's 'Format' tab and ensuring it expects a numeric input, or by utilizing a keystroke validation script to reject alphabetical characters.




