How to Remove Trailing Zeros from Number Fields in Adobe Acrobat
Question details
The user needs to format PDF number fields dynamically so that unnecessary trailing zeros are hidden while preserving necessary decimals.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Formatting an interactive PDF form where numeric inputs vary in decimal length.
- Observed behavior
- Acrobat's built-in Number format rigidly enforces a set number of decimal places, forcing whole numbers like '3' to display as '3.00'.
Ensure you have Adobe Acrobat Pro or Standard installed, as the free Adobe Reader version does not support creating or editing form field properties.
Apply a Custom JavaScript Format to the Number Field
By replacing the standard Number format with a custom JavaScript snippet, you can dynamically strip out trailing zeros after the decimal point.
The built-in Number format in Acrobat applies fixed decimal constraints. To achieve dynamic decimals, you must utilize the 'Custom' format category to run a simple script whenever a user inputs a number.
Open your PDF in Adobe Acrobat, navigate to the Tools menu, and select 'Prepare Form'.
Right-click on the specific number field you want to modify and choose 'Properties' from the context menu.
In the Properties dialog box, click on the 'Format' tab located at the top.
From the 'Select format category' dropdown menu, choose 'Custom'.
In the 'Custom Format Script' text box, paste the following code: event.value = util.printf("%,02.2f", event.value).replace(/\.?0+$/, "");
Click 'Close' to save the properties, exit Prepare Form mode, and type test numbers into the field to verify the behavior.

Edit and Manage PDF Forms Easily with WPS Office
WPS Office includes a powerful PDF editor that allows you to easily view, fill, and manage interactive PDF forms without the steep learning curve of complex scripting.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Fill the Form: Click directly into the form fields to input your data or numbers.
- 3. Edit the Document: Navigate to the 'Edit' tab to modify standard PDF text and elements if necessary.
- 4. Save Changes: Save the document to keep your form inputs and formatting intact.

Frequently Asked Questions
Why does the default number format add extra zeros?
Acrobat's built-in Number format uses a fixed decimal setting (usually 2 places) for visual uniformity across ledgers and invoices. It automatically pads whole numbers with zeros to meet this fixed length.
Do I need programming skills to fix this issue?
No programming experience is required. You simply need to copy and paste the provided one-line custom JavaScript code into the format script box of the field's properties.
Will this custom format script function correctly on mobile PDF readers?
JavaScript support varies significantly across mobile PDF readers. While the script works reliably in the desktop version of Adobe Acrobat and Adobe Reader, some third-party or basic mobile apps may fail to execute the formatting script.




