PDF Editing Issues

Truncate PDF Form Numbers to Three Decimal Places in Adobe Acrobat

Bushra ParveenBushra Parveen Nov 19, 2026 869 views

Question details

Set a PDF form field to accept values from 0 to 100 and truncate any digits beyond three decimal places.

Truncate PDF Form Numbers to Three Decimal Places in Adobe Acrobat
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A user is configuring a numeric PDF form field that must preserve up to three decimal places without rounding.
Observed behavior
The field should reject values outside the allowed range and remove extra decimal digits from valid values.
Before you start

Open the PDF in a version of Adobe Acrobat that can edit form fields, and identify the field you want to validate. The script below uses a period as the decimal separator and does not accept signs, commas, or scientific notation.

Solution 1Recommended

Add a custom validation script to the PDF form field

Use this method to check the original value against the range and truncate extra decimals when the user commits the field.

1
Open the form editor

In Adobe Acrobat, open the PDF and select All tools > Prepare a form. Select the numeric text field and open its Properties.

2
Disable number formatting

In the field's Format tab, choose None so a number format does not round the displayed value.

3
Add the validation script

In the Validate tab, select Run custom validation script, click Edit, and enter the following script: var value = String(event.value).replace(/^\s+|\s+$/g, ""); if (value !== "") { if (!/^(?:\d+(?:\.\d*)?|\.\d+)$/.test(value)) { app.alert("Enter a number between 0 and 100."); event.rc = false; } else { var parts = value.split("."); var whole = (parts[0] || "0").replace(/^0+(?=\d)/, ""); var fraction = parts[1] || ""; if (whole.length > 3 || (whole.length === 3 && whole > "100") || (whole === "100" && /[1-9]/.test(fraction))) { app.alert("Enter a number between 0 and 100."); event.rc = false; } else { var dot = value.indexOf("."); event.value = dot < 0 ? value : value.slice(0, dot + 4); } } }

4
Save and test the field

Close Properties, save the PDF, and enter test values in the field. For example, 12.3456 should become 12.345, while 100.0001 should be rejected.

Add a custom validation script to the PDF form field
Check form and viewer settings: The script permits an empty field. If a value is mandatory, select Required in the field's General properties. Test the saved form in a PDF viewer that supports Acrobat form JavaScript, with JavaScript enabled.
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 makes it easier to move existing documents into your workflow. Use Acrobat and a compatible PDF viewer for the custom form validation script described above.

Open and work with PDF documents alongside your other filesCompatible with Microsoft Office formats including DOCX and XLSXFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight suite for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Does the script check the range before truncating?

Yes. It checks the entered value first, so 100.0001 is rejected rather than changed to 100.000.

Why should I set the field format to None?

In the field's Properties > Format tab, choose None to prevent number formatting from rounding the displayed value independently of the validation script.

Can users leave the field blank?

Yes. The script allows an empty value. To require an entry, open the field's Properties > General tab and select Required.

Will the validation work in every PDF viewer?

No. The viewer must support Acrobat form JavaScript and have JavaScript enabled. Test the saved PDF in the viewer your users will use.