PDF Editing Issues

Fix Acrobat JavaScript Form Calculation Errors

John WilsonJohn Wilson Nov 19, 2026 868 views

Question details

Correct JavaScript calculations that use dropdown and text field values in an Acrobat PDF form.

Fix Acrobat JavaScript Form Calculation Errors
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form uses JavaScript to calculate a result from dropdown and text fields.
Observed behavior
The calculated field displays NaN, [object Field]0, or an unexpected zero.
Before you start

Open the PDF in Acrobat and choose Prepare a form. Identify the exact names of the input and calculated fields, and check whether dropdown options have numeric export values.

Solution 1Recommended

Read and convert field values in the calculation script

Use this approach when the script treats field objects as values or receives empty or nonnumeric input.

getField returns a field object, not its entered value. Use its .value property and convert numeric input before calculating; otherwise, concatenation can produce text such as [object Field]0.

1
Open the calculation script

In Prepare a form, open the calculated field's Properties, select the Calculate tab, and choose Custom calculation script > Edit.

2
Read and validate the inputs

Replace field names as needed and adapt this example to your formula: (function () { var a = this.getField('level1'); var b = this.getField('level2'); if (!a || !b) { event.value = ''; return; } var x = String(a.value).trim(); var y = String(b.value).trim(); if (x === '' || y === '') { event.value = ''; return; } var n1 = Number(x); var n2 = Number(y); if (!isFinite(n1) || !isFinite(n2)) { event.value = ''; return; } event.value = Math.floor(n1 + n2); }).call(this);

3
Check dropdown values

In Prepare a form, open the dropdown field's Properties and check the Options tab. Ensure each option used in the calculation has a numeric export value, or update the script to map text choices to numbers.

4
Test the result

Save the script, close the field properties, and test the form with numeric, empty, and nonnumeric inputs. If the inputs are calculated fields, use Prepare a form > More > Set Field Calculation Order to place them before the result field.

Read and convert field values in the calculation script
Adjust the formula and rounding: The example adds two inputs and rounds down. Replace n1 + n2 with your intended calculation, and use Math.floor or Math.ceil only if that rounding is required. Rounding down a positive result below 1 produces 0.
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. Open common file formats to make migration easier, but use Acrobat to troubleshoot its JavaScript form calculations.

Open and review PDF forms alongside other documentsCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar editing interface for everyday Office tasksLightweight suite with free tools
microsoft office alternative - wps office

Frequently Asked Questions

Why does my calculated field show [object Field]0?

The script is likely combining a field object with another value. In the calculated field's custom calculation script, use the object's .value property and convert it with Number() when the calculation needs a number.

What causes NaN in an Acrobat calculation?

NaN can appear when a value cannot be converted to a number. Check the input fields and dropdown export values, then validate converted values before assigning the result to event.value.

Why does my calculation return zero for an empty field?

Number('') returns 0. Check whether each field value is empty before conversion, and set event.value to an empty string if the calculation should wait for input.

How do I change the order of calculated fields?

In Acrobat's Prepare a form tool, choose More > Set Field Calculation Order. Place fields that supply calculated values before fields that depend on them.