How to Fix PDF Percentage Field Errors and Display a Blank Result
Question details
The user needs to fix a calculated PDF percentage field that shows format errors or 0% when source fields are empty, ensuring it displays a blank result and avoids division by zero.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating or filling out a PDF form with automatically calculated fields.
- Observed behavior
- The field attempts to divide by zero when source fields are empty, triggering an alert and displaying 0% instead of remaining blank.
Ensure you have editing permissions for the PDF document and access to the form field properties to apply custom calculation scripts.
Use a Custom Calculation Script to Validate Fields
Implement a JavaScript snippet that checks if source fields are empty or zero before performing the division to prevent errors.
In PDF forms, an empty field is typically evaluated as having a value of zero. When a calculation attempts to divide by an empty field, the system interprets it as dividing by zero, triggering an error alert.
By adding a custom calculation script, you can instruct the form to verify the values first and bypass the calculation entirely if the divisor is empty.
Open your PDF form in edit mode, right-click the target percentage field, and select Properties from the context menu.
Navigate to the Calculate tab within the properties window and choose the 'Custom calculation script' option.
Click Edit and insert a JavaScript logic that verifies if the source fields (e.g., your Cost field) have a value greater than zero. If the field is empty or zero, set the script to return an empty string to avoid calculation.
Click OK to save the script, close the properties window, and test the form by leaving the source fields blank to confirm no error alerts appear.

Apply a Custom Format Script to Hide 0%
Use a formatting script to display a blank space instead of 0% when the calculated value equals zero.
Easily Manage PDF Forms and Calculations with WPS Office
WPS Office provides advanced PDF editing tools, allowing you to easily create, modify, and manage form fields, including complex custom calculations and visual formatting.
- 1. Open PDF Form: Launch WPS Office and open your PDF document containing the interactive form fields.
- 2. Access Form Tools: Click on the Form tab in the top ribbon to access the interactive form editing tools.
- 3. Edit Field Properties: Double-click any form field to open its properties, where you can configure calculation logic and clean up display formats.

Frequently Asked Questions
Why does my PDF field show a division by zero error?
In PDF forms, an empty field is treated as having a value of 0. If your calculation attempts to divide by this empty field, it triggers an invalid division by zero error alert.
How do I make a PDF field blank instead of showing 0.00?
You can use a custom format script in the field's Properties menu. Set the script to check if the calculated value is zero, and if so, change the display output to an empty string.
Can I perform calculations in a PDF without using custom JavaScript?
Yes, simple calculations like sum, product, average, minimum, and maximum can be done using the built-in options in the Calculate tab. However, handling empty fields or applying conditional logic requires custom JavaScript.




