PDF Editing Issues

Fix NaN and Field Mismatch Errors in Acrobat Form Calculations

Jason MillerJason Miller Nov 18, 2026 870 views

Question details

The user needs a reliable Acrobat form calculation and instructions for entering it.

Fix NaN and Field Mismatch Errors in Acrobat Form Calculations
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A calculated PDF form field divides a fixed amount by twice the sum of three input fields.
Observed behavior
The calculation produces NaN or a field mismatch error when values are blank or the denominator is zero.
Before you start

Open the PDF in Adobe Acrobat and identify the exact names of the three input fields and the result field. Check that you can edit the form and that Acrobat JavaScript is enabled under Preferences > JavaScript.

Solution 1Recommended

Add a guarded custom calculation script in Acrobat

Use this script to treat blank inputs as zero and leave the result blank when a field is missing, a value is not numeric, or the denominator is zero.

The example calculates 18000 divided by twice the sum of Calc1, Calc2, and Calc3. Replace those names and the fixed amount if your form uses different fields or a different formula.

1
Open the form editor

Open the PDF in Acrobat, then choose All tools > Prepare a form. Select the field that should display the calculation result and open its Properties.

2
Enter the calculation script

In the result field's Properties, open the Calculate tab, select Custom calculation script, and click Edit. Paste this script: var f1 = this.getField("Calc1"); var f2 = this.getField("Calc2"); var f3 = this.getField("Calc3"); if (!f1 || !f2 || !f3) { event.value = ""; } else { var c1 = Number(f1.value); var c2 = Number(f2.value); var c3 = Number(f3.value); var x = c1 + c2 + c3; if (!isFinite(c1) || !isFinite(c2) || !isFinite(c3) || !isFinite(x) || x === 0) { event.value = ""; } else { event.value = 18000 / (2 * x); } }

3
Check field names and formatting

In Prepare a form, open each input field's Properties and confirm its name matches the script exactly. In the result field's Format tab, choose a suitable number format and check any validation settings if a format mismatch message still appears.

4
Test the form

Close the Properties dialog and use Preview in Prepare a form. Test blank fields, values that sum to zero, and valid numbers; for example, inputs totaling 100 should produce 90.

Add a guarded custom calculation script in Acrobat
Check calculation order: If Calc1, Calc2, or Calc3 are also calculated fields, use the form editor's calculation order command to place them before the result field.
Free Microsoft Office alternative

Work with PDF Forms 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 format support helps you move existing files into your workflow. Use Acrobat to edit and troubleshoot Acrobat-specific form calculation scripts.

Open PDF files and work with PDF forms alongside your other documentsCompatible with Microsoft Word DOCX and Excel XLSX filesFamiliar interface makes moving from Microsoft Office easierFree, lightweight office suite for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Where do I enter a custom calculation in Acrobat?

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

Why does my calculated field show NaN?

NaN means a calculation produced a value that is not a number. Check the input field names and values, convert inputs with Number(), and guard against nonnumeric values and a zero denominator.

What happens when the input fields are blank?

In the example script, Number() converts blank field values to zero. If all three values sum to zero, the result field is left blank instead of dividing by zero.

Why does Acrobat still report a field format mismatch?

Open the affected field's Properties in Prepare a form and check its Format and Validate tabs. Also confirm that the script references the exact input field names and returns a number when the result is not blank.

Can WPS Office repair an Acrobat calculation script?

Use Adobe Acrobat to edit and troubleshoot its custom form calculation script. WPS Office can be used to work with PDFs and compatible Office files, but it is not a direct repair tool for Acrobat-specific scripting errors.