Make PDF Fields Read-Only with Acrobat Checkbox JavaScript
Question details
Create a PDF form in which selecting one of three checkboxes makes the other checkboxes and related fields read-only or hidden.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form has three checkbox choices, each with associated fields, and only one choice should remain available at a time.
- Observed behavior
- Selecting a checkbox should restrict the other choices and their associated fields; clearing it should restore access.
In Acrobat's Prepare a form tool, check the exact names of the three checkboxes and their related fields. Enable Acrobat JavaScript and automatic field calculation in Preferences so the form can run its calculation script.
Use a hidden calculation field to control the form
Use this approach when selecting one checkbox should lock the other choices and their associated fields.
The example assumes checkboxes named check1, check2, and check3, with one related text field for each choice named field1, field2, and field3. Replace these names with the exact names in your form.
The script changes field properties but does not clear existing entries. It assumes no more than one checkbox is selected when the form is first opened.
Open the PDF in Acrobat, select Prepare a form, and add a text field. Open its Properties and set its visibility to Hidden on the General tab.
In the hidden field's Properties, open Calculate, select Custom calculation script, and click Edit. Enter: var c1 = this.getField("check1"); var c2 = this.getField("check2"); var c3 = this.getField("check3"); var s1 = c1.valueAsString != "Off"; var s2 = c2.valueAsString != "Off"; var s3 = c3.valueAsString != "Off"; c1.readonly = s2 || s3; c2.readonly = s1 || s3; c3.readonly = s1 || s2; this.getField("field1").readonly = s2 || s3; this.getField("field2").readonly = s1 || s3; this.getField("field3").readonly = s1 || s2;
Update the names in the script and add a corresponding readonly line for each additional related field. Save the PDF, select Preview in Prepare a form, and test each checkbox and its related fields. Clear the selected checkbox to check that the other choices become editable again.

Work with PDF and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for everyday document and PDF work. Its Office format support helps you move existing files into your workflow, though it does not replace Acrobat's JavaScript form configuration.

Frequently Asked Questions
Why does the script compare checkbox values with Off?
In Acrobat forms, an unchecked checkbox has the value Off. Comparing valueAsString with Off lets the script identify a selected checkbox without needing to know its export value.
Will clearing the selected checkbox unlock the other fields?
Yes. When no checkbox is selected and the calculation runs again, the example sets the other checkboxes and related fields back to editable.
Does making a field read-only erase its contents?
No. The readonly property prevents editing but leaves the existing value in place. Clearing values requires additional form logic.
What if the form does not respond to a checkbox selection?
Check the field names in Prepare a form, confirm that Acrobat JavaScript and automatic field calculation are enabled in Preferences, and test in Acrobat or another viewer that supports the required JavaScript.




