How to Preserve Manually Entered Values in PDF Calculation Fields
Question details
The user needs a way to prevent a custom JavaScript calculation script in a PDF form from erasing manually entered data when specific field conditions are not met.

- Product
- Adobe Acrobat / PDF Forms
- Device & OS
- not provided
- Scenario
- Filling out or designing interactive PDF forms where specific fields calculate values conditionally but should also permit permanent manual input.
- Observed behavior
- Manually entered text in the calculation field disappears and is replaced by an empty string as soon as the user clicks away or the field loses focus.
Ensure you have access to the form editing or preparation mode in your PDF editor to view and modify custom calculation scripts.
Update the JavaScript with event.rc = false
Explicitly tell the PDF viewer to ignore the calculated result when the condition is false, allowing the manual input to remain intact.
Calculation scripts in PDF forms run automatically whenever any field in the document changes. If a script continuously calculates a value but lacks an explicit instruction for a false condition, it will overwrite your manual entries with a blank string.
By adding the 'event.rc = false' statement to your script, you prevent the script from applying its calculated result. This effectively tells the software to leave the field alone, allowing manual entries to persist.
Right-click the target calculation field in your PDF editor's form preparation mode and select 'Properties' from the context menu.
Navigate to the 'Calculate' tab, ensure 'Custom calculation script' is selected, and click the 'Edit' button.
Update your script to handle the false condition. For example: `var a = this.getField("A").value; if (a == "EX") event.value = "EXAMPLE"; else event.rc = false;`. Ensure there are no missing quotation marks.
Click 'OK' to save the script, exit form editing mode, and test the field by entering a manual value to ensure it no longer disappears.

Edit and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive and user-friendly PDF editor that allows you to seamlessly view, fill out, and manage interactive PDF forms. Whether you need to input data into calculation fields or edit text directly, WPS Office handles standard PDF formats effortlessly.
- 1. Download and Install: Download WPS Office from the official website and open your interactive PDF document.
- 2. Access the Form Tools: Click on the fields to directly input your data. WPS PDF smoothly processes standard form formatting and background scripts.
- 3. Edit PDF Content: Use the 'Edit' tab if you need to modify static standard text, images, or layout elements directly within the PDF file.

Frequently Asked Questions
Why does my PDF form field clear itself automatically?
This usually happens because a custom calculation script is running in the background. Since calculation scripts trigger on any field change across the document, they will overwrite your manual entries with an empty string if they are not explicitly configured to ignore false conditions.
What does event.rc = false do in a PDF script?
The `event.rc = false` statement instructs the PDF software to reject or ignore the result of the calculation script. This preserves whatever value was manually entered or previously existed in the form field.
Can I use this JavaScript in any PDF viewer?
Advanced JavaScript for calculation fields is an Adobe Acrobat standard. While many premium PDF editors and modern viewers support these scripts, some basic web browsers or lightweight document viewers may not execute the JavaScript correctly.




