Make Two PDF Form Fields Mutually Exclusive in Adobe Acrobat
Question details
Make two corresponding PDF form fields mutually exclusive so that entering a value in either field prevents editing the other.

- Product
- Fillable PDF form
- Device & OS
- not provided
- Scenario
- A fillable PDF has paired fields in Column A and Column B, and users should enter a value in only one field in each pair.
- Observed behavior
- Entering a value in one field should make its paired field read-only; clearing the value should make the paired field editable again.
Open the fillable PDF in a form editor that supports field-level JavaScript, such as Adobe Acrobat Pro, and check the exact names of both fields. For each pair, start with both fields empty and editable.
Add validation scripts to both fields in Adobe Acrobat
Use this method to make each field control whether its paired field is editable.
Each validation script checks the value being committed and changes the paired field's read-only property. The change generally takes effect when the user leaves the field or otherwise commits the entry.
In Adobe Acrobat Pro, open the PDF and select Prepare a form. Identify the exact field names for the pair you want to control.
Open field A's Properties, select the Validate tab, and choose Run custom validation script. Select Edit and enter: this.getField("B").readonly = event.value == "" ? false : true;
Open field B's Properties, select the Validate tab, and choose Run custom validation script. Select Edit and enter: this.getField("A").readonly = event.value == "" ? false : true;
In each script, replace A or B inside getField with the exact name of the opposite field. Repeat for any other pairs using their respective field names, then save the PDF.
Open the saved PDF in Adobe Acrobat or Acrobat Reader. Enter a value in the first field and move focus away; confirm the second field is read-only. Clear the first field and move focus away, then repeat the test starting with the second field.

Work with PDF and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its Microsoft Office format support makes it easy to move existing files into WPS. Use a PDF editor that supports Acrobat form validation JavaScript for the conditional field behavior described above.

Frequently Asked Questions
Where can I find the exact names of the PDF form fields?
In Adobe Acrobat Pro, open Prepare a form and inspect the fields in the form editor. Open a field's Properties to check its name, then use that exact name in the other field's getField call.
When does the other field become read-only?
The validation script runs when the entry is committed, typically when the user moves focus away from the field. Clearing the value and committing the change makes the paired field editable again.
Can I use the same scripts for multiple rows?
Yes. Add the scripts to each pair and replace the names inside getField with the exact name of the opposite field in that row. Each pair needs its own corresponding field names.
Why does the form work in Acrobat but not in my browser?
Some browser PDF viewers do not support or allow Acrobat form JavaScript. Test the saved form in Adobe Acrobat or Acrobat Reader with JavaScript enabled.




