Fix Acrobat PDF Calculation Errors Caused by Text Values and Field Formatting
Question details
Fix a PDF form calculation that produces a field format error when input values differ by a small amount.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form uses a calculation script to read input fields with valueAsString and write a result to another field.
- Observed behavior
- The calculation produces a format error for some numeric values.
Open the PDF in Acrobat and select Prepare a form. Identify the input fields, the calculated result field, and their exact field names in the form editor.
Convert input values and check the calculated field
Use this approach when a custom calculation reads text values or reports that a result does not match the field format.
In Prepare a form, right-click the result field and select Properties. On the Calculate tab, select Custom calculation script and click Edit.
Replace the field names and arithmetic in your script as needed. For example: var s1 = this.getField("Input1").valueAsString.replace(/^\s+|\s+$/g, ""); var s2 = this.getField("Input2").valueAsString.replace(/^\s+|\s+$/g, ""); var n1 = Number(s1); var n2 = Number(s2); event.value = (s1 !== "" && s2 !== "" && isFinite(n1) && isFinite(n2)) ? n1 - n2 : ""; This leaves the result blank if either input is blank or invalid.
In the script editor, check that the result field is not read as one of its own inputs. If Act100uL is the calculated field, do not use its value to calculate Act100uL.
In the result field's Properties, open the Format tab and set the format category to None. Close Properties, preview the form, and test valid, blank, and invalid inputs.
After the calculation works, return to Properties > Format and choose the desired numeric format. Test the form again with the values that previously caused the error.

Work with PDF and Office files in WPS Office
WPS Office is a free, lightweight alternative for everyday PDF and Office work. Its familiar interface and format support make it easy to move existing documents into your workflow. Use Adobe Acrobat to troubleshoot Acrobat-specific form scripts.

Frequently Asked Questions
Why can valueAsString cause a calculation problem?
valueAsString returns text. Convert each input with Number() or parseFloat() before arithmetic, and explicitly handle blank or invalid values.
Where can I change the result field's format in Acrobat?
Select Prepare a form, right-click the result field, and choose Properties. On the Format tab, select None while testing, then restore the intended format.
What is a circular calculation in a PDF form?
It occurs when a calculated field depends on its own value, directly or through other fields. Open the result field's Calculate script and remove any dependency on the result field itself.
Why does Number() need a separate blank check?
Number() converts an empty string to zero. Check the trimmed input before conversion if a blank field should leave the result blank instead.




