How to Prevent PDF Calculated Fields from Overwriting Manual Entries
Question details
The user needs to prevent auto-calculated PDF form fields from overwriting values that have been manually entered by users.

- Product
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form with calculated fields, such as merging multiple address fields into one text box.
- Observed behavior
- Whenever a related input field changes, the calculated field automatically triggers a recalculation, which subsequently erases any custom data the user manually typed into that field.
Ensure you have a PDF editor that supports advanced form field properties and custom JavaScript calculations, such as Adobe Acrobat Pro. It is also highly recommended to save a backup copy of your PDF form before modifying any calculation scripts.
Use JavaScript to Restrict Calculation Triggers
By checking the event.source.name property in your custom JavaScript, you can instruct the form to run the calculation only when specific dependent fields change, successfully preserving direct manual edits.
A calculated field normally recalculates every time any related field in the document changes. To bypass this default behavior, the script must identify whether the change originated from a designated input field or from a direct user edit.
Enter Form Editing mode in your PDF editor. Right-click the calculated text field you wish to modify and select Properties from the context menu.
In the Properties dialog box, click on the 'Calculate' tab and select the 'Custom calculation script' option.
Click 'Edit' and wrap your calculation logic in an if statement that checks the event source against specific field names. For example: if (event.source.name == 'City' || event.source.name == 'State') { event.value = ... }.
Click 'OK' to save the script and close the dialog. Switch to Preview mode, manually type a value into the calculated field, and then alter the dependent fields to verify your manual entry is not overwritten.

Allow Manual Entry Only When Empty
A simpler script adjustment that stops the recalculation specifically if the user is typing into an empty field.
Manage Interactive PDF Forms Seamlessly with WPS Office
WPS PDF provides a comprehensive set of tools to read, edit, and fill interactive PDF forms. Whether you need to adjust text properties, fill out complex layouts, or merge documents, WPS Office offers a seamless and cost-effective alternative to heavy PDF editors.
- 1. Open Your PDF Document: Launch WPS Office and open your interactive PDF form document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available form interaction tools.
- 3. Fill or Edit Fields: Click on the text fields, checkboxes, or drop-down lists to interact with the form smoothly.
- 4. Save Your Form: Click the 'Save' icon or press Ctrl+S to securely save your updated PDF form data.

Frequently Asked Questions
Why does a calculated PDF field overwrite manual text?
By default, a PDF calculates its formula whenever any related field in the document changes. If a manual entry isn't protected by a conditional script, the automatic recalculation replaces the manually typed text with the formula's updated result.
Can I completely disable automatic calculation in a PDF form?
Yes, you can temporarily disable automatic calculations globally on your machine by going to Edit > Preferences > Forms, and unchecking 'Automatically calculate field values'. However, for form design intended for multiple users, it is best to handle this via custom scripts.
What is event.source.name in PDF JavaScript?
The event.source.name property in Acrobat JavaScript identifies the specific field name that triggered the calculation event. Utilizing this property allows scripts to respond conditionally based strictly on which form field the user just modified.
Does WPS Office support filling out interactive PDF forms?
Yes, WPS Office fully supports reading and filling out interactive PDF forms, including complex text fields, checkboxes, and drop-down lists, while maintaining excellent compatibility with standard PDF formatting.




