PDF Editing Issues

Make Specific Acrobat Form Sections Read-Only with JavaScript

Muhammad TalhaMuhammad Talha Nov 19, 2026 868 views

Question details

Make a button in a fillable PDF set only the fields in its corresponding section to read-only.

Make Specific Acrobat Form Sections Read-Only with JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A fillable PDF contains multiple sections, each with its own button for locking that section's fields.
Observed behavior
Each button should lock its designated fields without making the rest of the form read-only.
Before you start

Open the PDF in Acrobat and use Prepare a form to check the exact names of the fields in each section. Decide whether each button should only lock fields or also unlock them on a later click.

Solution 1Recommended

Add a JavaScript action to each section button

Use a button's Mouse Up action to set only the named fields in its section to read-only.

1
Open the form editor

In Acrobat, open the PDF and select All tools > Prepare a form. Check the field list for the names of the section's fields.

2
Open the button actions

Double-click the section's button, open the Actions tab, and select Mouse Up as the trigger. Choose Run a JavaScript as the action and click Add.

3
Enter the field-specific script

In the JavaScript editor, enter the following script for fields named Text1 through Text10, then click OK: for (var i = 1; i <= 10; i++) { var field = this.getField("Text" + i); if (field) field.readonly = true; }

4
Configure the other sections

Open the Actions tab for each remaining section button and add a script using that section's field names and range. For example, change the loop to 11 through 20 if the next section contains Text11 through Text20.

5
Save and test

Close the button properties, save the PDF, and exit form editing. Click each button and verify that its fields are read-only while fields in other sections remain editable.

Add a JavaScript action to each section button
Unlock fields or add a toggle: Set readonly to false instead of true to unlock the targeted fields. For a toggle, use the first field's current value to determine the new value and apply it to every field in that section. Test in a PDF viewer that supports Acrobat form JavaScript.
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 working with PDF and Office files. Its format compatibility helps you move existing documents into WPS; use Acrobat for the button JavaScript described above.

Open and work with PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface makes it easier to move from Microsoft OfficeFree, lightweight suite for everyday document tasks
QA img-9

Frequently Asked Questions

How do I find the exact names of my PDF form fields?

In Acrobat, open All tools > Prepare a form and check the field list or open a field's properties. The names in the script must match the form field names.

What if my section's fields are not numbered in sequence?

In the button's Run a JavaScript action, target each field by its exact name, such as this.getField("CustomerName").readonly = true, and repeat for the other fields in that section.

How can I make the fields editable again?

Add a button action that targets the same fields and sets readonly to false, or use a toggle script that switches the section's fields between true and false.

Why does the button work in Acrobat but not another PDF viewer?

PDF viewers differ in their support for form JavaScript. Test the saved form in Acrobat and check whether JavaScript is enabled in the viewer where the button fails.