PDF Editing Issues

Count Decimal Places in an Adobe Acrobat Form

Steven ParkerSteven Parker Nov 19, 2026 868 views

Question details

The user needs an Acrobat form field to count the digits after the decimal point in another field.

Count Decimal Places in an Adobe Acrobat Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
An interactive PDF form should calculate a decimal-place count from a source field.
Observed behavior
The desired count is 1 for 10.1, 2 for 10.01, 3 for 10.001, and 0 for a whole number.
Before you start

Open the PDF in an Acrobat edition that can edit form fields, and identify the exact name of the field containing the value. The script below expects a period as the decimal separator.

Solution 1Recommended

Add a custom calculation script to the result field

Use Acrobat's form calculation options to count the characters after the decimal point in a source field.

1
Open the form editor

In Adobe Acrobat, open the PDF and choose All tools > Prepare a form.

2
Check the field names

Select the source field and check its name in Properties. Create or select a separate text field to display the count.

3
Add the calculation

Open the result field's Properties, select Calculate, choose Custom calculation script, and click Edit. Enter: var x = this.getField("Text1").valueAsString; var decimal = x.split("."); event.value = decimal.length > 1 ? decimal[1].length : 0;

4
Use your source field name

In the script editor, replace Text1 with the exact name of your source field, then confirm the script and close Properties.

5
Test the form

Select Preview in Prepare a form and enter 10.1, 10.01, 10.001, and 10 in the source field. Check that the result field displays 1, 2, 3, and 0, respectively.

Add a custom calculation script to the result field
The count depends on the field's text: The script counts characters after the period in the value returned by valueAsString. Field formatting or a comma decimal separator can affect the result; use a text value that preserves any trailing zeros you need to count.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative for everyday document, spreadsheet, presentation, and PDF work. Its familiar interface and support for Microsoft Office formats make it easy to move existing files. It does not fix or replace the Acrobat-specific form calculation script above.

Open and work with PDF documents alongside other office files.Compatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTX.Use a familiar interface for everyday office tasks.Access a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the script return zero for a whole number?

The script splits the field's text at the period. If there is no period, it sets the result field to 0.

Where do I enter the field calculation script?

In Acrobat, open All tools > Prepare a form, open the result field's Properties, and select Calculate > Custom calculation script > Edit.

Will the script count trailing zeros?

It counts trailing zeros only if they are present in the text returned by the source field's valueAsString property. Check the field's formatting and test a value such as 10.00.

Can I use a comma as the decimal separator?

The provided script looks for a period. If your field consistently uses a comma instead, change split(".") to split(",") and test the form with your expected input.