How to Conditionally Format and Auto-Populate PDF Form Fields
Question details
The user wants to apply conditional formatting to a PDF form to hide calculated total fields when the quantity is zero, and automatically populate shipping fields based on billing information.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Designing an interactive PDF e-form that requires dynamic calculations, numeric formatting, and data duplication across matched fields.
- Observed behavior
- By default, calculated numeric fields display a zero when the quantity is empty or zero, and address fields require manual duplicate entry instead of auto-syncing.
Ensure your PDF form fields are properly named (e.g., 'Total', 'BillTo', 'ShipTo') and that your PDF editing software supports custom JavaScript actions and calculations.
Use Custom Format Scripts to Hide Zero Values
Apply a custom JavaScript format to keep the underlying field value numeric while displaying a blank space instead of a zero.
When a calculation results in zero, standard numeric formatting will display '0.00'. By replacing the standard format with a custom script, you can conditionally hide the zero so the form remains clean and ready for manual printing if needed.
Enter Form Editing mode in your PDF editor. Right-click the 'Total' field and select 'Properties'.
Click on the 'Format' tab. Under 'Select format category', choose 'Custom' from the dropdown menu.
In the 'Custom Format Script' box, enter the following code: event.value = (event.value == 0) ? "" : util.printf("$%,02.2f", event.value); and click 'OK'.

Auto-Populate Shipping Fields from Billing Fields
Use a checkbox with a built-in validation or calculation script to automatically copy billing details into shipping details.
Edit and Manage PDF Forms Easily with WPS Office
While complex dynamic workflows may require advanced JavaScript in specialized Adobe tools, WPS Office provides a highly intuitive PDF editor that lets you easily create, edit, fill, and sign standard interactive PDF forms without dealing with complicated code.
- 1. Open your PDF: Launch WPS Office and open the PDF form document you wish to edit.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal all interactive form controls.
- 3. Add and Edit Fields: Click on 'Text Field', 'Check Box', or 'Drop-Down' to place new interactive elements into your document.
- 4. Save and Distribute: Once your form is designed, save the document. It is now ready to be shared with users for easy filling and data collection.

Frequently Asked Questions
Why does my PDF total field show a zero instead of staying blank?
When a PDF field is formatted as a number or currency, the default calculation behavior interprets an empty input as zero. To display a blank field instead, you must use a custom format script that checks if the value is zero and replaces the display output with an empty string.
Can I automatically format item numbers or phone numbers in a PDF form?
Yes. In the field's Properties menu, under the Format tab, you can select 'Special' and enter an Arbitrary Mask (like spaces or hyphens) so users only have to type the raw numbers while the PDF auto-formats the spacing.
How do I make a PDF field calculate a total based on quantity and price?
Open the Total field's properties, go to the Calculate tab, and select 'Value is the product of the following fields'. Then, pick your 'Quantity' and 'Price' fields. The PDF will automatically multiply them.




