PDF Editing Issues

How to Make Acrobat PDF Form Fields Read-Only After Required Fields Are Complete

Jason MillerJason Miller Oct 28, 2026 869 views

Question details

The user wants to validate required PDF form fields using JavaScript and subsequently lock only the text fields to read-only before the form is submitted.

How to Make Acrobat PDF Form Fields Read-Only After Required Fields Are Complete
Product
Adobe Acrobat PDF
Device & OS
not provided
Scenario
Creating a custom submit action in a PDF form that enforces required data entry before permanently locking specific form elements.
Observed behavior
The current JavaScript routine locks all form fields indiscriminately before checking if required fields are filled, which prevents validation and incorrectly disables buttons or signatures.
Before you start

Ensure you have access to a PDF editor that supports advanced JavaScript for forms, and always keep a backup copy of your original editable PDF file before testing new validation scripts.

Solution 1Recommended

Use JavaScript to Validate and Selectively Lock Text Fields

Create a two-step script that first loops through fields to verify required entries, and then runs a second loop to lock only elements classified as text fields.

When designing interactive PDF forms, indiscriminately locking all fields during submission can break the process by disabling functional buttons and signature boxes. To avoid this, your JavaScript must separate validation from the property-changing actions.

The script will first ensure that every field flagged as 'required' has a valid value. Only when all mandatory conditions are met will the code proceed to change the properties of text fields to read-only.

1
Open the PDF in Form Editing Mode

Launch your PDF form in Adobe Acrobat. Navigate to the 'Tools' menu and select 'Prepare Form' to enter editing mode.

2
Add a Custom Action to the Submit Button

Right-click your intended 'Submit' button on the document and choose 'Properties'. Go to the 'Actions' tab, select 'Run a JavaScript' from the 'Select Action' dropdown, and click 'Add'.

3
Write the Validation Loop

In the JavaScript editor, create a loop iterating through 'this.numFields'. For each field, check if 'this.getField(fname).required' is true and if its current value matches its 'defaultValue' or is empty. If an empty required field is found, trigger an 'app.alert' and return out of the function to halt submission.

4
Write the Lock Loop for Text Fields

Below the validation loop, create a second loop that executes only if validation passes. Check the field type using 'this.getField(fname).type === "text"'. If true, set 'this.getField(fname).readonly = true'.

5
Trigger Form Submission

Add the final line of code to execute the actual submission process using 'this.submitForm(...)' with your required parameters, then click 'OK' and save your PDF.

Use JavaScript to Validate and Selectively Lock Text Fields
Targeting Correct Field Types: By explicitly targeting 'type === "text"', you ensure that signature fields, checkboxes, and navigational buttons remain fully functional after text input is locked.
Powerful PDF Form Editor

Edit and Manage PDF Forms Easily with WPS PDF

If you frequently work with interactive PDF forms and need a reliable, lightweight application, WPS Office provides an intuitive PDF tool to view, fill, and manage PDF forms effortlessly.

  1. 1. Open Your PDF Form: Launch WPS Office and open your interactive PDF form document.
  2. 2. Fill the Required Fields: Click directly on the highlighted form fields to enter your text, or check the necessary boxes.
  3. 3. Flatten the PDF: To quickly make all fields read-only and prevent further editing, go to 'Menu' > 'Print' and choose 'Print to PDF', or use the export functions to save a flattened version.
Fully compatible with standard Adobe PDF forms and interactive fields.Easily fill text fields, toggle checkboxes, and add electronic signatures.Save documents as flattened PDFs to instantly make all fields read-only without complex scripting.Lightweight, user-friendly interface as a free alternative to heavy PDF editors.
microsoft office alternative - wps office

Frequently Asked Questions

Why shouldn't I lock all PDF fields upon submission?

Locking all fields indiscriminately will also disable functional elements like the Submit button itself or digital signature fields, preventing users from successfully completing the signing or submission process.

How do I check a field type using PDF JavaScript?

You can access a specific field's type property using the syntax 'this.getField("FieldName").type'. Common return values include 'text', 'button', 'checkbox', and 'signature'.

Can I make fields read-only without using JavaScript?

Yes, you can manually set an individual field to read-only by right-clicking it in Form Editing mode, selecting Properties, and checking the 'Read Only' box under the General tab. However, making it dynamic based on required field validation requires JavaScript.