How to Reset a PDF Drop-Down on Invalid Radio Button Selection
Question details
The user needs a method to reset a specific drop-down field and display an error alert when an invalid combination of radio buttons is selected in an interactive PDF form.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or configuring an interactive PDF form with conditional logic to prevent incorrect data entry.
- Observed behavior
- The form needs to automatically clear the 'Month Reporting' drop-down and alert the user if 'Yes' is chosen for 'Full Year Reconciliation' without selecting the required 'Reconciliation' option.
Ensure you are using a PDF editor that supports JavaScript for form field validation, and verify that your drop-down menus and radio buttons are already created and precisely named.
Use a Custom JavaScript Validation Script
Add a custom validation script to the drop-down field to check the state of the radio buttons, display an alert, and reset the field if the selection criteria are not met.
In interactive PDF forms, JavaScript can be used to enforce conditional logic. By applying a validation script directly to the drop-down field, you can actively monitor the values of associated radio buttons.
When the invalid condition is detected, the script interrupts the input process, alerts the user, and clears the current field using the resetForm method.
Right-click the target drop-down field (e.g., 'Month Reporting') in your PDF editor's form editing mode and select 'Properties'.
In the Properties dialog box, navigate to the 'Validate' tab and choose the option to 'Run custom validation script'.
Click the 'Edit' button and input your conditional statement to check the values of the radio buttons. For example, check if 'Full Year Reconciliation' is 'Yes' while 'Reconciliation' is empty.
Inside the failing condition of your script, add app.alert('Your error message'); to warn the user. Then, reject the input by setting event.rc = false; and clear the drop-down by adding this.resetForm([event.target.name]);.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to effortlessly create, edit, and manage interactive PDF forms. Easily set up field properties, configure conditional logic, and ensure your data collection is accurate.
- 1. Open Your PDF: Launch WPS Office and open your interactive PDF document in the PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal all interactive form controls and editing tools.
- 3. Configure Properties: Double-click any form field to open its properties panel, where you can define names, export values, and validation rules.

Frequently Asked Questions
What does event.rc = false do in a PDF validation script?
Setting event.rc = false in a PDF validation script rejects the user's current input. It prevents the invalid selection from being committed to the form field, forcing it to revert or remain empty.
Why isn't my PDF form reset script working?
This typically occurs if the field names referenced in your JavaScript do not exactly match the actual field names in the form (they are case-sensitive). It can also happen if JavaScript is disabled in the user's PDF viewer.
Can I reset multiple PDF form fields at once using JavaScript?
Yes, you can pass an array of field names to the reset method. For example, using this.resetForm(['Dropdown1', 'RadioBtn2']); will clear both specified fields simultaneously.




