How to Prevent a PDF Dropdown from Selecting a Value in Another Field
Question details
The user needs to configure a PDF dropdown list to reject any value that matches the content of a separate text field.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form that requires conditional field validation to prevent duplicate data entry.
- Observed behavior
- Using a Mouse Down script fails to reliably prevent the selection and causes repeated clicks instead of rejecting the duplicate value.
Ensure you have a PDF editor that supports interactive form fields and JavaScript validation, and verify the exact name of the text field you plan to reference.
Use a Custom Validation Script in the Dropdown Field
Move the logic to the dropdown's Custom Validation Script to reliably evaluate and reject duplicate values before they are committed.
Using a Mouse Down script is unreliable for field validation because it interferes with the clicking action rather than the data entry. Instead, the Custom Validation Script allows the PDF reader to evaluate the selected value and reject it immediately if it matches another field's value.
Open your PDF form in editing mode, right-click the target dropdown field, and select 'Properties' from the context menu.
In the Properties dialog box, go to the 'Validate' tab and select the option 'Run custom validation script'.
Enter the following JavaScript code into the script window: event.rc = event.value != this.getField("TextField").valueAsString; if (!event.rc) { app.alert("This value cannot be selected", 1); }
Replace the generic 'TextField' in the script with the exact, case-sensitive name of the separate text field you want to check against.
Close the properties window, save your PDF document, and test the dropdown to ensure it displays the alert and rejects the matching value.

Create and Edit Advanced PDF Forms with WPS Office
WPS PDF provides robust, easy-to-use tools for creating interactive forms, managing dropdowns, and configuring advanced field properties to streamline your data collection.
- 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to make interactive.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to access all interactive field controls.
- 3. Insert form elements: Select tools like 'Combo Box' (Dropdown) or 'Text Field' to add new interactive elements to your document.
- 4. Customize properties: Double-click any form field to open its properties, where you can define appearance, lists, and advanced behaviors.

Frequently Asked Questions
Why doesn't a Mouse Down script work for PDF dropdown validation?
A Mouse Down script triggers exactly when the user clicks the field. This causes repeated script executions and interferes with the physical click process, making it incapable of reliably intercepting or rejecting the data value after a selection is made.
What does event.rc do in a PDF JavaScript validation?
The event.rc property acts as a return code during the validation phase. Setting event.rc to false signals to the PDF viewer that the input value is invalid, causing it to reject the user's selection and revert the field to its previous state.
How do I find the exact name of a text field in my PDF form?
Open your PDF in form editing mode, then double-click or right-click the target text field to view its Properties. The exact, case-sensitive field name will be displayed under the 'General' tab.




