PDF Editing Issues

Make PDF Fields Read-Only with Acrobat Checkbox JavaScript

Camila MilosovichCamila Milosovich Nov 19, 2026 868 views

Question details

Create a PDF form in which selecting one of three checkboxes makes the other checkboxes and related fields read-only or hidden.

Make PDF Fields Read-Only with Acrobat Checkbox JavaScript
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.
Before you start

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.

Solution 1Recommended

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.

1
Add a calculation field

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.

2
Add the script

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;

3
Adapt and test the form

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.

Use a hidden calculation field to control the form
Hiding fields and viewer support: To hide a related field instead of making it read-only, set its display property using display.hidden or display.visible under the same condition. Test the saved form in the PDF viewer recipients will use: not all viewers support Acrobat JavaScript or form calculations.
Free Microsoft Office alternative

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.

Open and work with PDFs alongside other documentsCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight suite for everyday productivity
microsoft office alternative - wps office

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.