PDF Editing Issues

Prevent Entries in One PDF Form Column When Another Is Used

Maira MehtabMaira Mehtab Nov 19, 2026 868 views

Question details

Configure two PDF form columns so that entering data in either column prevents entries in the other.

Product
PDF forms
Device & OS
not provided
Scenario
A form has two columns intended to be mutually exclusive.
Observed behavior
The desired behavior is for the opposite column to become unavailable when one column contains an entry.
Before you start

Check whether each column is a single form field or a group of fields, and note the exact field names. The example below uses two initially empty text fields and requires a PDF editor and viewer that support Acrobat JavaScript.

Solution 1Recommended

Use Acrobat JavaScript to Lock the Opposite Form Field

Use this method when each column consists of one text field and you can edit the form in Adobe Acrobat.

The validation script makes the opposite field read-only when an entry is committed. Clearing the entry and leaving the field makes the opposite field editable again.

The example assumes both fields start empty. If a column contains multiple fields, the script must check all fields in that column and lock or unlock all fields in the opposite column.

1
Identify the fields

Open the PDF in Adobe Acrobat and choose All tools > Prepare a form. Select each column's text field and check its name in Properties > General. For this example, name the fields ColumnA and ColumnB.

2
Add the validation script

Open ColumnA's Properties, select Validate, choose Run custom validation script, and click Edit. Paste the script below, then repeat the same steps for ColumnB: var otherName = event.target.name === "ColumnA" ? "ColumnB" : "ColumnA"; var otherField = this.getField(otherName); var hasEntry = String(event.value || "").replace(/^\s+|\s+$/g, "").length > 0; if (otherField) otherField.readonly = hasEntry;

3
Save and test the form

Save the PDF and open it in a JavaScript-capable PDF viewer. Enter text in ColumnA and move focus away; check that ColumnB is read-only. Clear ColumnA, move focus away, and repeat the test starting with ColumnB.

Viewer support matters: PDF viewers that disable or do not support Acrobat JavaScript may not enforce this behavior. Test the form in the viewer recipients will use.
Free Microsoft Office alternative

View and Edit PDFs Alongside Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Open existing files to make migration easy; use a JavaScript-capable PDF editor and viewer for the conditional form behavior described above.

Open PDFs alongside documents and spreadsheetsCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight office suite
QA img-9

Frequently Asked Questions

When does the opposite field become read-only?

With the validation script, the opposite field is updated when the entry is committed, typically after the user moves focus away from the edited field.

What if each column contains several fields?

In Acrobat's Prepare a form tool, identify every field in each column. The script must check whether any field in the active column contains data and set the read-only property for all fields in the opposite column.

Why does the form still allow entries in both columns?

Check that the field names in the script match those in Properties > General and that the script is installed under Validate for both fields. Also test in a viewer that supports and enables Acrobat JavaScript.

Can users switch to the other column after entering data?

Yes. In the two-field example, clear the populated field and move focus away. Its validation script then makes the opposite field editable again.