PDF Editing Issues

Fix an Acrobat PDF Form Calculation Script That Returns Blank

Steven ParkerSteven Parker Nov 19, 2026 868 views

Question details

Correct a PDF form calculation so it divides two field values and returns zero when the numerator is blank or zero.

Fix an Acrobat PDF Form Calculation Script That Returns Blank
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A calculated form field should divide a numerator by a denominator while handling blank or zero inputs.
Observed behavior
The custom calculation script returns a blank value instead of the expected result.
Before you start

Open the PDF in an Acrobat edition that lets you edit form fields, and check the exact names of the numerator and denominator fields. Make sure the PDF permits form editing.

Solution 1Recommended

Replace the Custom Calculation Script with Numeric Checks

Use this script to convert field values to numbers and return zero when either value is blank, invalid, or zero.

1
Open the form editor

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

2
Open the result field properties

Double-click the field that should display the calculated result, then select the Calculate tab.

3
Enter the calculation script

Select Custom calculation script and click Edit. Replace the existing code with: var numerator = Number(getField("GOALPATIENTSRow1_2").value) || 0; var denominator = Number(getField("GOALDAYSRow1_2").value) || 0; event.value = (numerator === 0 || denominator === 0) ? 0 : numerator / denominator;

4
Check field names and test

Replace the names inside getField() if your fields have different names. Close the properties, then enter test values in the form, including a blank numerator, a zero denominator, and two nonzero numbers.

Replace the Custom Calculation Script with Numeric Checks
Use standard quotation marks: Keep straight quotation marks around field names. This script treats values that cannot be converted to numbers as zero.
Free Microsoft Office alternative

Work with PDF and Office Files in WPS Office

WPS Office is a free, lightweight alternative for everyday document work, with a familiar interface and support for common Office formats to make migration easier. It does not fix Acrobat-specific form calculation scripts.

Open and review PDF documents alongside other filesCompatible with Microsoft Word, Excel, and PowerPoint formatsUse familiar document, spreadsheet, and presentation toolsMove between common file formats in one lightweight suite
microsoft office alternative - wps office

Frequently Asked Questions

Where do I put the calculation script in Acrobat?

Choose All tools > Prepare a form, double-click the result field, and open Calculate > Custom calculation script > Edit.

Why does the script check the denominator for zero?

Dividing by zero does not produce a usable form result. The script sets event.value to zero when the denominator is blank, invalid, or zero.

How do I find the correct field names?

In Prepare a form, double-click each input field and check its name in the field properties. Use those exact names in the getField() calls.

What if the result does not update after I change an input?

Check Acrobat's Forms preferences to make sure automatic field calculation is enabled. If the input fields are themselves calculated, also check the field calculation order in Prepare a form.