PDF Editing Issues

Keep an Acrobat PDF Form Calculation Blank When Inputs Are Empty

Jason MillerJason Miller Nov 19, 2026 869 views

Question details

Keep a calculated PDF form field blank until both input fields have values.

Keep an Acrobat PDF Form Calculation Blank When Inputs Are Empty
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form calculates column3 minus column2 plus 1 in a result field.
Observed behavior
The result field displays 1 when the input fields are blank.
Before you start

Open the PDF in Adobe Acrobat and confirm the exact names of the two input fields and the result field in Prepare a form. Check that the input fields have no default value if they should start blank.

Solution 1Recommended

Add a custom calculation script to the result field

Use a custom calculation to leave the result blank until both input fields contain data.

1
Open the form editor

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

2
Open result field properties

Right-click the result field, such as column4, and select Properties. Open the Calculate tab.

3
Enter the calculation script

Select Custom calculation script, click Edit, and enter the following script. Replace column3 and column2 with your exact input field names if they differ: var column3 = this.getField("column3").valueAsString; var column2 = this.getField("column2").valueAsString; if (column3 === "" || column2 === "") { event.value = ""; } else { event.value = (Number(column3) - Number(column2)) + 1; }

4
Save and test the form

Click OK to save the script, close the field properties, and use Preview in Prepare a form. Test both blank fields, each field blank individually, and two numeric inputs, including zero.

Add a custom calculation script to the result field
Check numeric formatting: The script expects values that JavaScript's Number function can read, such as 12 or 3.5. Formatting such as thousands separators or locale-specific decimal separators may require additional parsing.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Microsoft Office files. It can help you move between document formats, but it does not replace Acrobat's custom form calculation editor.

Open and review PDF forms alongside other documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight office suite for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does the calculation show 1 when both fields are blank?

The calculation can treat blank inputs as zero, making the expression 0 minus 0 plus 1 equal 1. A custom calculation script can check for blank inputs before calculating.

Where do I put the calculation script in Acrobat?

Open All tools > Prepare a form, right-click the result field, and choose Properties. On the Calculate tab, select Custom calculation script and click Edit.

Will the script calculate when an input is zero?

Yes. The script checks the fields' string values for an empty string, so a value of 0 is treated as an input rather than as a blank.

What should I check if the result is still incorrect?

In Prepare a form, verify that the field names in the script match the input fields exactly. Test the number format as well: separators such as commas may not be accepted by JavaScript's Number function.