How to Hide a Zero Third Decimal Place in Acrobat Percentage Fields
Question details
The user needs to hide the third decimal place in a PDF percentage field dynamically, but only when its value is zero.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up dynamic number formatting for interactive fields in a PDF form.
- Observed behavior
- The percentage field currently displays three decimal places at all times, regardless of whether the third digit is a zero or a significant number.
Ensure you have access to Adobe Acrobat Pro or a PDF editor that supports adding custom JavaScript to form fields, and back up your original PDF form before testing new scripts.
Apply Custom JavaScript for Dynamic Formatting
Use a custom JavaScript formatting script instead of standard percentage formatting to conditionally drop the trailing zero.
Standard formatting options in Acrobat force a fixed number of decimal places. To dynamically hide a trailing zero, you must bypass the standard percentage format and use custom JavaScript. The built-in AFPercent_Format function can sometimes support this, but writing a custom formatting script offers more reliable control.
Open your PDF in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form'.
Right-click the specific percentage field you want to modify and select 'Properties' from the context menu.
Go to the 'Format' tab. In the 'Select format category' dropdown, choose 'Custom'.
In the 'Custom Format Script' box, enter your JavaScript. You can experiment with the undocumented function by typing 'AFPercent_Format(2, 0)' or write a custom regex script that checks the field's event.value, formats it to three decimal places, and strips the trailing zero if it exists.
Click 'Close', switch to 'Preview' mode, and test the field with values having both two and three significant decimal places to ensure the formatting behaves exactly as expected.

Manage and Edit PDF Documents Easily with WPS Office
If you are looking for a highly compatible and cost-effective way to handle PDFs and office documents, WPS Office provides a powerful, lightweight alternative for viewing, editing, and managing your files with ease.
- 1. Download the Application: Visit the official WPS website and download the free WPS Office suite for your operating system.
- 2. Open Your PDF: Launch the WPS PDF tool from the suite and open your existing PDF document or interactive form.
- 3. Edit and Save: Use the integrated PDF tools to read, annotate, or fill out your documents, then save them seamlessly in standard formats.

Frequently Asked Questions
Why doesn't the standard percentage format drop trailing zeros?
Standard number and percentage formatting in PDF forms applies a strictly fixed number of decimal places for visual consistency. To make the decimal places dynamic based on the input value, custom JavaScript is required.
Can I hide trailing zeros in Acrobat without using JavaScript?
No, Acrobat's built-in formatting dropdowns only allow you to select a fixed number of decimal places (e.g., exactly 2 or 3). Any conditional or dynamic formatting behavior must be scripted.
How do I access the JavaScript console in Acrobat to debug my script?
You can open the JavaScript Debugger by pressing Ctrl+J on Windows or Cmd+J on Mac. This console will display any syntax errors or runtime issues occurring in your custom formatting scripts.




