How to Hide Zero Values in Calculated PDF Form Fields
Question details
The user needs to make a calculated PDF form field appear blank when its result is zero, ensuring unnecessary zeros do not show on printed forms while retaining the zero value for subsequent calculations.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form with calculations, aiming for a clean print output without cluttered zero values.
- Observed behavior
- The form currently displays a visible '0' when the calculation evaluates to zero, which prints on the page and clutters the document layout.
Ensure your form fields are correctly designated as calculated number fields. It is highly recommended to save a backup of your PDF form before applying or editing any JavaScript code.
Use a Custom Format Script to Hide the Displayed Zero
The most efficient way to hide a zero without deleting it is to apply a Custom Format script. This makes the field visually empty but keeps the underlying value intact for other mathematical formulas.
Applying a custom format script allows you to separate the visual presentation of a form field from its actual calculated data. By only altering the display, dependent form fields won't break.
Open your PDF form editor, right-click the calculated field you want to modify (such as the 'Total' field), and select 'Properties' from the context menu.
In the Field Properties dialog box, click on the 'Format' tab. From the 'Select format category' dropdown menu, choose 'Custom'.
In the 'Custom Format Script' text box, type the following exact code: if (event.value == 0) { event.value = ""; }
Click 'Close' to save your changes. Enter values into your form to test the calculation. When the result is exactly zero, the field will now appear completely blank.

Hide the Entire Field Using a Calculation Script
If you need to control the visibility of the field box itself (not just the text inside it), you can write a script to hide the field element when the total reaches zero.
Create and Manage PDF Forms with WPS Office
WPS PDF provides a comprehensive set of tools for creating, editing, and managing interactive PDF forms. Whether you need to adjust text fields, checkboxes, or format settings, WPS Office makes professional form handling straightforward and accessible.
- 1. Open your PDF: Launch WPS Office and open your interactive PDF form document.
- 2. Access form tools: Navigate to the 'Form' tab located on the top navigation ribbon to reveal all form-editing capabilities.
- 3. Modify fields: Double-click any text field or number box to open its properties and modify formats or calculations.
- 4. Save your document: Once your adjustments are made, save the PDF to preserve all updated form behaviors and properties.

Frequently Asked Questions
Will hiding the zero value break my other formulas?
No. When you use the Custom Format script (event.value = ""), you are only changing how the number is displayed on the screen and in print. The underlying data remains '0', so any dependent mathematical formulas will continue to calculate perfectly.
Why do printed PDF forms display zeros by default?
By default, PDF calculation fields explicitly display their exact numerical value to maintain data accuracy. If a mathematical calculation evaluates to zero, it outputs a '0'. While mathematically correct, this can look cluttered on printed invoices or forms, which is why custom formatting scripts are often used.
Can I apply the formatting script to multiple form fields at once?
You generally need to apply the Custom Format script to each calculated field individually through the Properties menu. However, because the script is identical for every field (if (event.value == 0) { event.value = ""; }), you can easily copy it and paste it into the format tab of each relevant field.




