PDF Editing Issues

Format Acrobat Form Numbers with Up to Three Decimal Places

Steve KSteve K Nov 19, 2026 869 views

Question details

Display numbers in an Acrobat form field with up to three decimal places and no unnecessary trailing zeros.

Format Acrobat Form Numbers with Up to Three Decimal Places
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form field needs to accept numeric entries while preserving only meaningful decimal digits.
Observed behavior
Values such as 4.250 should display as 4.25, while 3.125 should remain 3.125.
Before you start

Open the PDF in an Acrobat version that can edit form fields, such as Acrobat Pro. Check that JavaScript is enabled in Acrobat Preferences and that the field does not use a fixed-decimal number format.

Solution 1Recommended

Validate and Normalize the Acrobat Form Field

Use a custom validation script to remove trailing zeros and reject values with more than three meaningful decimal places.

The script accepts ordinary numbers using a period as the decimal separator. It removes leading zeros and trailing decimal zeros, so 04 and 4.0 both display as 4.

1
Open the field properties

In Acrobat, open the PDF and select All tools > Prepare a form. Double-click the numeric text field to open its properties.

2
Remove fixed-decimal formatting

On the Format tab, select None from the format category list so a fixed number of decimal places is not reapplied.

3
Add the validation script

On the Validate tab, select Run custom validation script and click Edit. Enter: var s = String(event.value).trim(); if (s !== "") { if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/.test(s)) { app.alert("Enter a valid number using a period as the decimal separator."); event.rc = false; } else { var decimals = (s.split(".")[1] || "").replace(/0+$/, ""); if (decimals.length > 3) { app.alert("Enter no more than three meaningful decimal places."); event.rc = false; } else { event.value = String(Number(s)); } } }

4
Save and test the form

Close the field properties and save the PDF. Preview the form and enter 4.250, 3.125, and 3.1251; the first two should display as 4.25 and 3.125, and the last should be rejected.

Validate and Normalize the Acrobat Form Field
Validation does not round: Entries with more than three meaningful decimal places are rejected rather than rounded. Form JavaScript must be supported and enabled in the PDF viewer.
Free Microsoft Office alternative

Work with PDFs and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Its format compatibility helps you move existing documents into your workflow; use Acrobat for the form JavaScript configuration described above.

Open and work with PDF documents alongside office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar tools make the transition from Microsoft Office easierLightweight suite with free tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does 4.250 display as 4.25?

The validation script converts the entry to a number and back to text, removing trailing zeros that do not change its value.

Will the script round a value such as 3.1251?

No. It rejects the entry because it has more than three meaningful decimal places. The user must enter a value with three or fewer.

Why do zeros reappear after validation?

The field may have a fixed-decimal format. In Prepare a form, open the field properties and set the Format tab's category to None.

Can I use a comma as the decimal separator?

The supplied script expects a period, such as 4.25. A comma-based entry requires a different validation script that accounts for the intended locale.

Will the formatting work in every PDF viewer?

No. The viewer must support and allow Acrobat form JavaScript. Test the saved form in the viewer your recipients will use.