How to Make PDF Form Calculations Display Zero for Empty Fields
Question details
The user needs a PDF form calculation field to display 0 instead of an incorrect partial result when the source input fields are left blank, ensuring it also works on mobile PDF viewers like Adobe Reader.

- Product
- Device & OS
- not provided
- Scenario
- Creating or configuring automated calculations inside a fillable PDF form with standard constants.
- Observed behavior
- Simplified field notation formulas (e.g., F0*50+60) return the constant (60) when the source field (F0) is blank, rather than evaluating the entire expression to 0.
Ensure you have a capable PDF editor with form editing permissions installed, and identify the exact names of the input fields causing the calculation errors.
Use Custom Calculation Scripts for Conditional Output
Apply a custom JavaScript calculation to explicitly check if the source field is empty and force the result to 0.
Standard simplified field notation treats empty fields as 0. If your formula contains an addition or subtraction (like +60), the calculation evaluates 0*50+60, which outputs 60. To prevent this, you must use conditional logic via a custom calculation script.
Right-click the target calculation field in your PDF editor's form editing mode and select Properties.
Click on the Calculate tab at the top of the Properties dialog box.
Choose the 'Custom calculation script' option and click the 'Edit' button to open the JavaScript editor.
Type the following script, replacing 'F0' with your actual field name: if (this.getField("F0").valueAsString == "") { event.value = 0; } else { event.value = (this.getField("F0").value * 50) + 60; }
Click OK to save the script, close the properties window, and test the form by leaving the input field blank and then entering a number.

Hide Results for Empty Fields (No JavaScript Workaround)
Format the field to remain completely blank if the value evaluates incorrectly, providing a cleaner look without relying on complex mobile JavaScript.
Create and Calculate PDF Forms with WPS Office
WPS Office provides powerful PDF form editing tools, allowing you to easily set up text fields, checkboxes, and custom calculation scripts without needing expensive software.
- 1. Open the PDF Form: Launch WPS Office, open your PDF document, and navigate to the 'Form' tab on the top ribbon.
- 2. Edit Field Properties: Double-click the form field you want to calculate to open the Text Field Properties panel.
- 3. Set Up Calculations: Switch to the 'Calculate' tab and choose 'Simplified field notation' or 'Custom calculation script'.
- 4. Input and Save: Input your formula or JavaScript logic, close the properties window, and save your PDF.

Frequently Asked Questions
Why does my PDF calculation return a value when fields are empty?
Standard PDF form calculations treat empty input fields as 0. If your formula contains constants (e.g., adding 60), the system evaluates 0 + 60, resulting in 60 instead of treating the entire calculation as 0.
Will custom JavaScript calculations work on Adobe Reader for mobile?
JavaScript support is limited and inconsistent on mobile PDF viewers (including Adobe Reader for iOS and Android). Complex scripts, specifically field validation or conditional formats, might not execute automatically without user interaction.
Can I set a default value of 0 for my input fields instead?
Yes. In the field properties under the Options tab, you can set the Default Value to 0. This ensures calculations always have a valid, visible number to process, avoiding unexpected blank field behaviors.
How do I use simplified field notation correctly?
Simplified field notation allows basic arithmetic using field names (like Field1 + Field2). However, it does not support conditional statements like IF/THEN. For logic that depends on whether a field is blank, you must use a Custom Calculation Script.




