How to Display N/A Instead of Zero in a Calculated PDF Form Field
Question details
The user needs to display the text N/A instead of the number zero in a calculated PDF form field while keeping the numeric zero intact for background calculations.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Formatting calculated fields in PDF forms to meet specific legal, regulatory, or reporting visual requirements.
- Observed behavior
- By default, a calculated field resulting in zero displays as 0.00, which needs to be visually overridden to display as N/A without breaking other dependent formulas.
Ensure that your PDF editing software supports JavaScript for form fields, and verify that your document is not locked for editing. It is recommended to save a copy of your PDF before applying custom scripts.
Apply a Custom JavaScript Format Script
Use a simple JavaScript snippet in the field's formatting properties to conditionally display N/A when the calculated value is zero, leaving the actual numeric value intact for other calculations.
By applying a script at the formatting level rather than the calculation level, the PDF retains the numeric 0.00 value for math operations while visually outputting your desired text string.
Open the PDF in your form-editing software and activate the Form Editing or Prepare Form mode to reveal all editable fields.
Right-click the specific calculated form field you want to modify and select Properties from the context menu.
Navigate to the Format tab. From the format category drop-down list, select Custom to allow JavaScript input.
Enter the following script into the Custom Format Script box: if (event.value != 0) event.value = util.printf('$%,0.2f', event.value); else event.value = 'N/A';
Save the properties and exit form editing mode. Test the form with positive, negative, and zero inputs to ensure dependent calculations remain functional and the field displays N/A when zero.

Create and Manage PDF Forms with WPS Office
WPS Office provides robust PDF editing tools, allowing you to easily create interactive forms, manage form fields, and handle document formatting efficiently in a single, lightweight application.
- 1. Open your PDF: Download and launch WPS Office, then open your PDF document containing the forms.
- 2. Navigate to form tools: Click on the Form tab on the top ribbon to access the interactive form editing tools.
- 3. Edit field properties: Select any form field to adjust its properties, customize formatting, and set up validation rules easily.

Frequently Asked Questions
Will displaying N/A break other calculations that rely on this field?
No. Using a custom format script changes only the displayed text, while the underlying value used in mathematical calculations remains as a numeric zero.
Why doesn't the script work after I paste it into the PDF?
Ensure you have placed the script in the 'Custom Format Script' section under the Format tab, rather than in the Calculation or Validation tabs. Also, check that JavaScript execution is enabled in your PDF reader's security preferences.
Can I apply this format script to multiple form fields at once?
Generally, you will need to paste the custom format script into the properties of each specific field individually, as field formatting rules are applied on a per-field basis.




