How to Hide Zero Results in Acrobat Form Calculations Using JavaScript
Question details
The user wants to suppress or hide zero (0) values in calculated PDF form fields, preferring them to display as blank.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up a PDF form where calculation fields automatically output a '0' before any data is entered, which clutters the document visually.
- Observed behavior
- The calculated form field defaults to displaying '0' when the underlying mathematical calculation evaluates to zero.
Ensure you are using Adobe Acrobat Pro or a PDF editor that supports JavaScript form calculations, and make a backup copy of your PDF file before applying custom scripts.
Use a Custom Validation Script to Suppress Zeros
Apply a brief JavaScript snippet to the form field's calculation or validation settings to clear the field whenever the value equals zero.
When using Acrobat's built-in sum or product calculations, the software automatically populates a zero if the source fields are empty. By injecting a custom validation script, you can intercept this zero and force the field to display as blank, preserving the clean look of your form without breaking the underlying calculation logic.
Open your PDF document in Adobe Acrobat, navigate to the 'Tools' menu, and select 'Prepare Form'.
Right-click the calculated form field you want to modify and select 'Properties' from the context menu.
Go to the 'Calculate' or 'Validate' tab (depending on where your primary calculation resides). Select 'Run custom validation script' or 'Run custom calculation script', then click the 'Edit' button.
Type the following script exactly as shown: if (event.value == 0) event.value = "";
Click 'OK' to close the JavaScript editor, then click 'Close' on the Properties window. Preview your form to ensure the zero is hidden and test dependent fields to confirm the blank value does not disrupt other calculations.

Easily Manage and Fill PDF Forms with WPS Office
While creating complex JavaScript calculations requires advanced tools, filling out, viewing, and managing interactive PDF forms is seamless with WPS PDF. As a comprehensive Office suite, WPS provides a fast and lightweight PDF editor for your daily document needs.
- 1. Download WPS Office: Visit the official WPS website to download and install WPS Office for free.
- 2. Open Your PDF Form: Launch WPS PDF and open your interactive PDF form document.
- 3. Fill Out the Form: Click directly into the text fields, checkboxes, or calculated fields to enter your data seamlessly.
- 4. Save or Export: Click 'Save' to preserve your inputted form data, or easily export the document for sharing.

Frequently Asked Questions
Why does my PDF form show zeros before I enter any data?
By default, Acrobat evaluates empty fields involved in mathematical formulas as zero. Consequently, the calculation field outputs a visible '0' until actual data is entered.
Will hiding the zero affect other calculations in my PDF?
Using the script 'event.value = "";' changes the output to an empty string. While standard Acrobat calculations usually handle empty strings gracefully, it is highly recommended to test your form thoroughly to ensure dependent calculations do not return errors.
Can I hide zero results without using JavaScript?
No. Acrobat's built-in simple field-entry calculations (like Sum or Product) natively output zeros. Suppressing these zeros specifically requires the use of a custom JavaScript snippet.




