PDF Editing Issues

How to Make a PDF Form Field Read-Only Based on Another Field's Value

Phi Hung VoPhi Hung Vo Nov 3, 2026 869 views

Question details

The user needs to configure a PDF form so that entering a value in one field automatically disables (makes read-only) another field.

How to Make a PDF Form Field Read-Only Based on Another Field's Value
Product
Adobe Acrobat / PDF Editors
Device & OS
not provided
Scenario
Creating an interactive accounting or data entry PDF form where two fields (such as debit and credit) are mutually exclusive, preventing users from filling out both.
Observed behavior
The user wants the credit field to lock and become read-only dynamically whenever the debit amount entered is greater than zero.
Before you start

Ensure you are using a PDF editor that supports JavaScript execution for form fields, and note down the exact, case-sensitive names of both the trigger field and the target field.

Solution 1Recommended

Apply a Custom JavaScript Validation Script

Use a short JavaScript snippet in the field's properties to dynamically change the read-only status of the target field based on the input value.

PDF forms support JavaScript to create dynamic interactions. By adding a validation script to the first field (e.g., Debit), you can command the PDF viewer to check the inputted number and lock the second field (e.g., Credit) if the condition is met.

1
Open Form Editing Mode

Open your PDF document in your PDF editor and enter 'Prepare Form' or 'Form Editing' mode to reveal all form fields.

2
Access Field Properties

Right-click the trigger field (for example, the 'Debit' field) and select 'Properties' from the context menu.

3
Navigate to the Validate Tab

In the Properties dialog box, click on the 'Validate' tab, then select the option 'Run custom validation script'.

4
Enter the JavaScript Code

Click the 'Edit' button and enter the following code: this.getField("Name of other field").readonly = (Number(event.value) > 0); Replace "Name of other field" with the exact name of your target field.

5
Apply Mutual Exclusion (Optional)

If you need both fields to disable each other, repeat these steps on the second field, swapping the field name in the script to point back to the first field.

Apply a Custom JavaScript Validation Script
Field Name Accuracy: JavaScript in PDFs is strictly case-sensitive. Ensure that the field name placed inside the quotation marks matches the target field's name exactly.
WPS PDF Editor

Create and Manage Interactive PDF Forms with WPS Office

WPS Office provides an easy-to-use, powerful PDF editor that allows you to seamlessly create, fill, and manage interactive PDF forms without needing expensive software.

  1. 1. Open Your Document: Launch WPS Office and open your PDF document using the WPS PDF tool.
  2. 2. Navigate to the Form Tab: Click on the 'Form' tab in the top navigation ribbon to access all interactive form controls.
  3. 3. Insert Form Fields: Select the desired field type (Text Field, Check Box, etc.) and click on the page to place it.
  4. 4. Adjust Properties: Double-click the inserted field to modify its name, appearance, and basic interactive properties, then save the document.
Easily insert text fields, checkboxes, drop-down menus, and radio buttons.Fully compatible with standard Adobe Acrobat PDF formats and interactive elements.Lightweight, fast-loading PDF editing experience with a familiar tabbed interface.Completely free to view and fill interactive forms on Windows, Mac, and mobile.
QA img-9

Frequently Asked Questions

Why isn't the target field locking when I type a value?

This usually happens for three reasons: the field name in your script doesn't match the actual target field name (remember it's case-sensitive), your PDF viewer has JavaScript disabled in its security settings, or you haven't tabbed out of the trigger field to commit the value.

Can I make multiple PDF form fields read-only at the same time?

Yes. You can expand your custom validation script by adding additional lines for each field. For example: this.getField("Field2").readonly = (Number(event.value) > 0); this.getField("Field3").readonly = (Number(event.value) > 0);

Will this JavaScript validation work on mobile PDF readers?

JavaScript support varies significantly across mobile PDF apps. While the script will work perfectly on desktop software like Adobe Acrobat or WPS Office, mobile users might not experience the dynamic locking effect if their app does not support advanced PDF JavaScript.