Make a Calculated Adobe Acrobat Form Field Blank When Its Value Is Zero
Question details
The user wants a calculated PDF form field to appear blank when its result is zero.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A calculated form field should show a value only when the calculation result is not zero.
- Observed behavior
- A script using event.item produces an error instead of replacing the zero result with a blank value.
Open the PDF in Adobe Acrobat and identify the calculated field and the source fields it uses. Make sure the field uses a custom calculation script, or locate the existing calculation before editing it.
Use event.value in the field's calculation script
Add a zero check after the calculation so the field displays an empty value when the result is zero.
Open the PDF in Adobe Acrobat and select Prepare a form from the tools.
Double-click the calculated field, open the Calculate tab, and select Custom calculation script. Click Edit.
Keep the existing calculation and add this line after it assigns the result to event.value: if (event.value == 0) event.value = ""; Do not use event.item for the current field value.
Check the complete script for balanced parentheses and braces, then confirm the dialog. Close form editing and change a source field to test both zero and nonzero results.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for common file formats, making it easy to move between Office documents and PDFs. It does not fix Acrobat JavaScript errors, and some PDF features may require a subscription.

Frequently Asked Questions
Why doesn't event.item work in my Acrobat script?
Acrobat JavaScript does not use event.item for the current field value. In a custom calculation script, use event.value to read or set the calculated result.
Where should I add the zero check?
In Prepare a form, open the field's properties, select Calculate, and edit its custom calculation script. Add the check after the existing calculation assigns a result to event.value.
Will the field still display nonzero results?
Yes. The line if (event.value == 0) event.value = ""; changes the value only when it compares equal to zero. Test the form with both zero and nonzero source values.
What if the script still reports a syntax error?
Reopen the custom calculation script and check the entire script for missing or extra parentheses, braces, and quotation marks. The line containing event.item may not be the only part that needs correction.




