PDF Editing Issues

Keep an Adobe Acrobat Calculation Field Blank Until Both Inputs Are Entered

Ayan MasoodAyan Masood Nov 19, 2026 869 views

Question details

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

Keep an Acrobat Calculation Field Blank Until Both Inputs Are Entered
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form subtracts one input field from another in a calculated result field.
Observed behavior
The result field displays zero before both source fields are filled in.
Before you start

Open the form in a version of Acrobat that can edit form fields, and note the exact names of the two input fields. The example below assumes both inputs are numeric and subtracts the second value from the first.

Solution 1Recommended

Add a custom calculation script to the result field

Use this script when the result should remain blank until both input fields contain values.

1
Open the form editor

Open the PDF in Adobe Acrobat and select Tools > Prepare a Form, or choose Prepare a form from the available tools.

2
Check the input field names

Double-click each source field and check its name in the General tab of Field Properties. Note the exact spelling, spaces, and capitalization.

3
Edit the result calculation

Double-click the result field, open the Calculate tab, select Custom calculation script, and click Edit.

4
Enter the script

Paste the following script into the JavaScript editor, replacing both example names with your actual field names: (function () { var s1 = getField("Form Field 1").valueAsString; var s2 = getField("Form Field 2").valueAsString; if (s1 && s2) { event.value = Number(s1) - Number(s2); } else { event.value = ""; } })();

5
Save and test the form

Click OK to close the script editor and field properties, then save the PDF. Enter values in both source fields and clear either one to verify that the result becomes blank.

Zero is a valid input: The script treats an entered zero as a value. Make sure the source fields accept numeric input and test the form in a PDF viewer that supports Acrobat form JavaScript.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight alternative for everyday document and PDF work, with a familiar interface and support for common Microsoft Office formats to help you migrate existing files. Use Adobe Acrobat for the custom PDF calculation script described above.

Open and read PDF forms alongside your other documentsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar editing tools make existing Office files easier to work withFree core tools in a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Where do I find the custom calculation script setting in Acrobat?

Open Prepare a Form, double-click the result field, and select Calculate > Custom calculation script > Edit.

Why does the result stay blank after I enter both values?

Check the source field names in Field Properties and make sure they match the names in the script exactly, including spaces and capitalization. Also test in a PDF viewer that supports form JavaScript.

Will the script calculate if one input is zero?

Yes. An entered zero is read as the nonempty string "0", so the calculation runs once the other field also has a value.

How can I change the subtraction to addition?

In the custom calculation script, replace the minus sign in Number(s1) - Number(s2) with a plus sign, then save and test the form.