How to Leave Calculated PDF Form Fields Blank When Input is Empty
Question details
The user wants to prevent calculated Minimum and Maximum PDF form fields from showing default numerical values when the dependent input field is empty.

- Product
- PDF Forms
- Device & OS
- not provided
- Scenario
- Creating or filling out interactive PDF forms that rely on automatic field calculations based on user input.
- Observed behavior
- Calculated fields incorrectly display numerical values such as 0 or 10 instead of remaining blank when the target input field contains no data.
Ensure your PDF form is opened in an editor that supports JavaScript form calculations and identify the exact field names used for your inputs.
Use Custom JavaScript to Check for Empty Input Strings
Implement a custom calculation script that verifies if the input field is empty before performing the mathematical operation.
By default, PDF forms often treat empty strings as zero during calculations. To prevent this, you need to explicitly check the input as a text string before converting it to a number. If the text string is empty, you can force the event value to remain empty as well.
Open your PDF form in editing mode, right-click the calculated field (e.g., Minimum or Maximum), and select 'Properties' from the context menu.
In the Field Properties dialog box, click on the 'Calculate' tab to view the calculation options for that specific field.
Select the 'Custom calculation script' radio button and click the 'Edit' button to open the JavaScript editor.
Enter a script to check for an empty string. For example: var s = this.getField("neutral").valueAsString; if (s == "") { event.value = ""; } else { var n = Number(s); event.value = n >= 10 ? n - 10 : 0; }
Apply equivalent blank-checking logic to any other calculated fields. Click 'OK', close the properties window, and test your form by leaving the input field blank.

Create and Edit Advanced PDF Forms Easily with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to design interactive forms, manage text fields, and configure document properties seamlessly.
- 1. Open Your Document: Download and install WPS Office, then open your PDF document using the WPS PDF tool.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access various form controls and interactive editing tools.
- 3. Modify Field Properties: Double-click any form field to open its properties, where you can adjust calculation settings, formatting, and custom actions.

Frequently Asked Questions
Why do my PDF form fields show a zero instead of staying blank?
PDF readers evaluate empty number fields as zero by default during calculations. You must use a custom JavaScript logic to detect an empty string and explicitly command the field to return an empty value.
Can I apply this calculation script to multiple fields at once?
No, you need to apply the custom calculation script individually to each calculated field's properties, ensuring you reference the correct target field names for each specific output.
Does this calculation script work in all PDF viewers?
Custom JavaScript calculations work perfectly in robust PDF editors like Adobe Acrobat and WPS PDF. However, some basic browser-based PDF viewers or mobile apps may not fully support JavaScript form calculations.




