How to Set a Calculated PDF Field to Blank When Reference Fields Are Empty
Question details
The user needs to configure a calculated field in a PDF form so that it remains blank instead of showing zero when all the reference input fields are empty.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form where a total cost field relies on multiple input fields like quantity, material, and labor.
- Observed behavior
- By default, Acrobat evaluates empty reference fields as zero, causing the calculated field to display '0' or '0.00' even before any user data is entered.
Verify whether your form needs to treat blank inputs differently from actual zero values, and ensure no conflicting number formats are applied to the total field, as they can override a blank output.
Use a Custom JavaScript Calculation Script
Replace standard field calculations with a custom JavaScript snippet that checks if all input fields are empty before performing the math.
When using the default 'Value is the sum of' option in Acrobat, the software automatically treats empty fields as zeros. To output a true blank string, you must use a custom calculation script that provides logical conditions.
Open your document in Adobe Acrobat, go to 'Tools', and select 'Prepare Form' to enable form editing.
Right-click the calculated field (e.g., the COST field) and select 'Properties' from the context menu.
Navigate to the 'Calculate' tab inside the Properties dialog. Choose the 'Custom calculation script' radio button and click 'Edit'.
Write a script that retrieves the values of your reference fields as strings. Use an 'if' statement to check if they are all empty. If true, set 'event.value = "";'. Otherwise, convert the strings to numbers and add them together.
Click 'OK' to save the script, then click 'Close' on the Properties window. Click 'Preview' at the top right to test the form fields.

Edit and Fill PDF Forms Easily with WPS Office
WPS Office offers a comprehensive PDF editor that makes it incredibly easy to fill interactive forms, manage documents, and execute standard calculations without the heavy resource usage of traditional PDF software.
- 1. Install WPS Office: Download and install the free WPS Office suite on your computer or mobile device.
- 2. Open Your PDF: Launch WPS Office and open your interactive PDF form.
- 3. Fill the Form: Click directly into the form fields to enter your data. WPS PDF smoothly handles standard automated calculations.
- 4. Save and Export: Once completed, save your changes or export the document for sharing without altering its original formatting.

Frequently Asked Questions
Why does my calculated PDF field show a zero instead of staying blank?
By default, PDF form engines evaluate empty numeric fields as zero. If you use the standard sum or product calculation tools, the result of empty fields will output as zero rather than remaining blank.
Does the field format affect my custom calculation script?
Yes. If a field's format is explicitly set to 'Number' with predefined decimal places, the software might override a blank value generated by JavaScript and display '0.00'. Adjusting the format to 'None' usually resolves this.
Can I hide zero values without using JavaScript?
While some PDF viewers allow users to uncheck 'Show zero values' in their local application preferences, this only affects the viewer locally. To ensure the form behaves identically for everyone, a custom JavaScript calculation is required.




