PDF Editing Issues

Remove Decimal Places from a PDF Form Field in Acrobat JavaScript

Huda QurayshiHuda Qurayshi Nov 18, 2026 869 views

Question details

Display only the integer portion of a number in an Acrobat PDF form field without leaving a decimal point.

Remove Decimal Places from a PDF Form Field in Acrobat JavaScript
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A PDF form uses JavaScript to remove decimal digits from a numeric field.
Observed behavior
The script removes the decimal digits but leaves a trailing decimal point, displaying a value such as 36. instead of 36.
Before you start

Open the PDF in a version of Acrobat that supports editing form fields, and identify the field whose displayed value needs to change. Check whether its values can be negative, because Math.floor() does not truncate negative numbers toward zero.

Solution 1Recommended

Truncate the displayed value with a custom format script

Use this approach to display the integer portion without rounding or a trailing decimal point, including for negative values.

A custom format script changes the field's displayed value; it does not necessarily change the value stored in the form. Math.floor() works for nonnegative numbers, while Math.ceil() truncates negative numbers toward zero.

1
Open the form field properties

In Acrobat, open the PDF and select Prepare a form. Right-click the target field and choose Properties.

2
Open the custom format script

Select the Format tab, choose Custom from the format category menu, and open Edit for the custom format script.

3
Enter the truncation script

Replace the existing custom format script with: if (event.value !== "" && !isNaN(Number(event.value))) { var n = Number(event.value); event.value = n < 0 ? Math.ceil(n) : Math.floor(n); }

4
Save and test the form

Close the script editor and field properties, save the PDF, and test the field with values such as 36.7 and -36.7. They should display as 36 and -36.

Truncate the displayed value with a custom format script
Avoid rounding down negative values: Math.floor(-36.7) returns -37, not -36. If all values are nonnegative, event.value = Math.floor(event.value); is sufficient for numeric input.
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 Office documents. Its Microsoft Office format compatibility helps make migration straightforward, though it does not fix Acrobat form JavaScript.

Open and review PDF documents alongside other office filesCompatible with Microsoft Office formats, including DOCX, XLSX, and PPTXFamiliar interface for users moving from Microsoft OfficeFree and lightweight suite for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF field show 36. instead of 36?

The script may be removing digits after the decimal point while leaving the point itself. In the field's Properties > Format settings, use a custom format script that converts the value to a number and truncates it.

Does Math.floor() remove decimals from negative numbers?

Math.floor() rounds toward negative infinity, so Math.floor(-36.7) returns -37. To remove the decimal portion toward zero, use Math.ceil() for negative values and Math.floor() for nonnegative values.

Will a custom format script change the stored form value?

A custom format script controls how the field value is displayed and does not necessarily change its stored value. If the underlying value must also be an integer, adjust the relevant calculation or validation script and test the result.

Can I use Acrobat's number format with zero decimal places instead?

In the field's Properties > Format tab, you can choose Number and set decimal places to zero. This may round the value rather than truncate it, so use a custom script if you need to discard the fractional portion.