How to Keep a Calculated PDF Form Field Blank Until Values Are Entered
Question details
The user wants to prevent a calculated PDF form field from showing '0.00' when no input has been provided.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive fillable PDF form with calculated fields.
- Observed behavior
- The calculated total field displays 0.00 by default, rather than remaining blank until related fields contain numbers.
Ensure you are opening your document in a PDF editor that supports form editing and custom JavaScript formatting, such as WPS Office PDF or Adobe Acrobat.
Apply a Custom Format Script to the Calculation Field
Replace the default number format with a custom JavaScript snippet to evaluate the field and hide zero values.
By default, standard Number formatting in PDF forms evaluates empty related fields as zero, resulting in a '0.00' display. Applying a simple custom format script overrides this behavior, ensuring the field stays clean and blank until actual data is entered.
Open your PDF document in your PDF editor. Navigate to the 'Form' tab and ensure you are in Form Editing mode so you can interact with form field properties.
Right-click on the calculated total field that is currently displaying 0.00 and select 'Properties' from the context menu.
In the Properties dialog box, go to the 'Format' tab. Click on the 'Select format category' dropdown menu and choose 'Custom'.
In the 'Custom Format Script' text box, enter the following code: event.value = (event.value != 0) ? util.printf("%,0.2f", event.value) : "";
Click 'Close' to save the properties, exit Form Editing mode, and test your form. The field will now remain blank until related values are entered, at which point it will format the result to two decimal places.

Create and Edit Advanced PDF Forms with WPS Office
WPS Office provides comprehensive PDF editing tools, allowing you to easily create interactive fillable forms, set up advanced field calculations, and apply custom formatting scripts without hassle.
- 1. Open Your PDF: Launch WPS Office and open your PDF document within the PDF editing workspace.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access a complete set of form creation and editing tools.
- 3. Customize Fields: Insert text fields, double-click to access their properties, and set up calculations or custom formatting scripts as needed.
- 4. Save and Share: Save your newly interactive PDF document. The standard PDF format ensures compatibility for anyone filling out your form.

Frequently Asked Questions
Why does my PDF form field show 0.00 by default?
When a form field is configured to perform a calculation and formatted as a 'Number', it automatically evaluates empty input fields as zero. This causes the total field to display 0.00 before any data is entered.
Can I hide zero values in PDF forms without using JavaScript?
Most advanced PDF editors default to showing zeros when basic number formatting is applied. Using a simple custom JavaScript format is the most universally reliable way to hide zeros in standard PDF forms.
Does this custom format script affect the actual field calculation?
No, the format script only dictates how the value is displayed on the screen. The underlying calculation remains accurate and will process normally as soon as valid data is entered into the referenced fields.
Will this JavaScript formatting work on mobile PDF viewers?
Standard desktop PDF readers and full-featured PDF applications support JavaScript formatting. However, some basic mobile PDF viewers or web browser extensions might not execute form scripts, which could result in the field behaving differently on those specific platforms.




