How to Format PDF Calculated Fields as Currency Without Showing $0.00
Question details
The user needs a calculated PDF field to display as currency (with a dollar sign, comma separators, and two decimal places) but remain blank instead of showing '$0.00' when the source field is empty.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF form with calculation fields for financial or pricing data.
- Observed behavior
- Applying standard currency formatting automatically outputs '$0.00' when the referenced source field is blank, which clutters the form.
Ensure you have access to the form editing mode in your PDF editor and are comfortable pasting custom JavaScript into field properties.
Apply a Custom JavaScript Format Script
Bypass the standard currency format and use a custom script to conditionally format the value based on whether the source field is empty.
Standard formatting rules in PDF forms interpret empty fields as zero, thus outputting $0.00. By switching to a custom format script, you can intercept the value and instruct the form to render an empty string when no input is detected.
Enter form editing mode, right-click the calculated field you want to modify, and select 'Properties' from the context menu.
Navigate to the 'Format' tab. Change the 'Select format category' dropdown from 'Number' (or whatever standard currency format you are using) to 'Custom'.
In the 'Custom Format Script' text box, enter the following code: event.value = ((event.valueAsString == "") || isNaN(event.value)) ? "" : util.printf("$%,0.2f", event.value);
Click 'Close' to save the properties. Exit form editing mode and test your form by leaving the source fields blank to confirm the calculated field remains empty.

Create and Manage Interactive PDF Forms in WPS PDF
WPS PDF provides powerful, intuitive form editing tools that let you create, edit, and apply advanced formatting to calculation fields with ease.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document containing the forms.
- 2. Access Form Tools: Navigate to the 'Form' tab in the top menu to enter interactive form editing mode.
- 3. Edit Field Properties: Double-click any text field to modify its calculation logic and formatting settings.
- 4. Save Changes: Export or save your document to finalize the interactive form functions.

Frequently Asked Questions
Why does my PDF field show $0.00 by default?
When standard currency formatting is applied, the PDF viewer's calculation engine treats an empty source field as a zero value, automatically appending the dollar sign and decimal places to it.
Can I use this script for other currency symbols?
Yes, you can modify the util.printf portion of the script. For example, replacing the '$' with '€' or '£' in util.printf("€%,0.2f", event.value) will format the output for Euros or Pounds.
Where exactly do I paste the custom calculation script?
In the field properties dialog box, go to the 'Format' tab, select 'Custom' from the format category dropdown menu, and paste the code into the 'Custom Format Script' window.




