PDF Editing Issues

Display Integers Without Decimals in an Adobe Acrobat Number Field

Nimra MalikNimra Malik Nov 24, 2026 868 views

Question details

Format a PDF form field so whole numbers appear without decimals and other numbers appear with two decimal places.

Display Integers Without Decimals in an Adobe Acrobat Number Field
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form uses a comma as the decimal separator and should display values such as 5,12 and 5.
Observed behavior
The desired field format shows two decimal places for non-whole values and no decimal separator or trailing zeros for whole numbers.
Before you start

Open the PDF in an Acrobat version that lets you edit form fields, and confirm that the field is editable. The script below accepts a comma or period as the decimal separator but does not accept thousands separators.

Solution 1Recommended

Apply a custom format script to the Acrobat form field

Use a custom format script to show whole numbers without decimals and other values with two decimal places.

The script formats values for display using a comma as the decimal separator. Values are rounded to two decimal places; if the rounded result is a whole number, its decimal portion is removed.

1
Open the field properties

In Acrobat, open the PDF and choose All tools > Prepare a form. Right-click the number field and select Properties.

2
Select a custom format

Open the Format tab, choose Custom from the format category menu, and click Edit next to Custom Format Script.

3
Enter the format script

In the script editor, enter: var s = String(event.value); if (/^\s*[-+]?\d+(?:[.,]\d+)?\s*$/.test(s)) { var n = Number(s.replace(',', '.')); if (isFinite(n)) { var f = n.toFixed(2); event.value = /\.00$/.test(f) ? f.replace(/\.00$/, '') : f.replace('.', ','); } }

4
Save and test the field

Click OK, close the field properties, and save the PDF. Exit form editing and enter 5, 5,1, and 5,12 in the field; after leaving the field, they should display as 5, 5,10, and 5,12.

Apply a custom format script to the Acrobat form field
Input and viewer limitations: This format script leaves unsupported input unchanged and does not validate it. PDF viewers vary in their support for Acrobat JavaScript, so test the saved form in the viewer your recipients will use.
Free Microsoft Office alternative

Prepare formatted number data with WPS Office

WPS Office is a free, lightweight alternative for working with spreadsheet data and exporting documents to PDF. Its familiar interface and Microsoft Office format compatibility make it easy to move existing files, but it does not replace the Acrobat JavaScript needed for this interactive PDF field.

Work with numeric data in WPS Spreadsheets before exporting a static PDF.Open and edit Microsoft Excel formats such as XLSX and XLS.Use a familiar spreadsheet interface when moving from Microsoft Office.Create and view PDF documents in a lightweight office suite.
QA img-9

Frequently Asked Questions

Where do I add the format script in Acrobat?

Choose All tools > Prepare a form, right-click the field, and select Properties. On the Format tab, choose Custom and click Edit next to Custom Format Script.

How can I display a period instead of a comma?

In the script's final assignment, replace f.replace('.', ',') with f. Non-whole values will then display with a period, such as 5.12.

Will a value such as 5,1 display with two decimal places?

Yes. With the supplied script, entering 5,1 displays as 5,10 after you leave the field. Entering 5 displays as 5.

Does the script prevent invalid entries?

No. The format script changes supported numeric values for display but leaves unsupported input unchanged. Use the field's Validate tab or a separate validation script if you need to reject invalid entries.

Will the formatting work in every PDF viewer?

Not necessarily. The viewer must support the Acrobat JavaScript used by the form. Test the saved PDF in the viewer your recipients plan to use.