How to Allow User Input in a PDF Custom Calculation Script
Question details
The user wants to enable manual data entry in a calculated text field only when a specific radio button (such as "New") is selected, without losing the automatic calculation functionality for the other radio button options.

- Product
- Adobe Acrobat / PDF Editors
- Device & OS
- not provided
- Scenario
- Designing dynamic PDF forms where a text field normally calculates a value automatically but occasionally requires custom manual input based on the user's choices.
- Observed behavior
- By default, a calculated field continuously runs its script and overwrites any manual user input. The goal is to conditionally pause this calculation script to accept custom data.
Ensure your PDF editor supports JavaScript for form calculations. Take note of the exact field names for your radio buttons and text fields, as JavaScript is strictly case-sensitive and mismatched names will cause the script to fail.
Use a Custom Calculation Script with a Mouse-Up Action Trigger
Implement a script that assigns fixed values for standard choices and preserves user entry when the custom choice is selected, combined with an action to reset the field.
To prevent a calculation script from overwriting a user's manual input, the script must verify the current state of the radio button group. If the custom option (e.g., 'New') is selected, the script should bypass the calculation entirely.
Additionally, you must add an action to the custom radio button itself so that selecting it clears any previously calculated value and prompts the user to type.
Right-click the calculated text field in your PDF form editor and select 'Properties'. Navigate to the 'Calculate' tab.
Select the 'Custom calculation script' option and click 'Edit'. Enter an if/else script that checks the radio button value. For example, instruct the script to only calculate a value if the radio button group value is not equal to 'New'.
Close the text field properties and right-click the 'New' radio button. Select 'Properties' and go to the 'Actions' tab.
Set the Select Trigger dropdown to 'Mouse Up' and the Select Action dropdown to 'Run a JavaScript'. Click 'Add' to open the JavaScript editor.
Type a short script to clear the text field and place the cursor inside it, such as: this.getField('YourTextFieldName').value = ''; this.getField('YourTextFieldName').setFocus(); Click OK to save.

Create and Manage Interactive PDF Forms with WPS Office
WPS PDF provides excellent tools for creating, filling, and managing interactive PDF forms. Whether you need to insert text fields, radio buttons, or checkboxes, WPS makes PDF form editing straightforward and efficient without requiring complex programming.
- 1. Open your PDF Document: Launch WPS Office and open your PDF file using the built-in WPS PDF editor.
- 2. Access the Form Tab: Navigate to the 'Form' tab on the top ribbon to view all available interactive form controls.
- 3. Insert Form Controls: Click on the required form fields, such as text fields or radio buttons, and place them directly onto your document.
- 4. Edit Field Properties: Double-click any inserted field to modify its properties, including its name, appearance, and default text.
- 5. Save and Test: Once your form fields are configured, save the document and switch to the hand tool to test the interactivity.

Frequently Asked Questions
Why does my text field clear user input automatically?
If a text field has a calculation script applied without a conditional check, the script will run every time any field on the form changes. This continuously overwrites whatever the user typed with the output of the calculation.
Can I use this method for dropdown menus instead of radio buttons?
Yes. You can apply the exact same conditional JavaScript logic based on the selected value of a dropdown menu (Combo Box) to enable or disable custom inputs in a separate text field.
How do I fix syntax errors in my PDF JavaScript?
Ensure that all field names in your script exactly match the names of your form fields, paying close attention to uppercase and lowercase letters. Also, verify that all brackets and quotation marks are properly closed in the script editor.




