PDF Security & Access Issues

How to Lock PDF Form Fields So Only the Correct User Can Unlock Them

Bushra ParveenBushra Parveen Oct 28, 2026 869 views

Question details

The user needs to configure a PDF form so that two different users can lock and unlock specific fields, but strictly enforce that only the user who locked a field can unlock it.

How to Lock PDF Form Fields for Specific Users
Product
Adobe Acrobat / LiveCycle Designer
Device & OS
not provided
Scenario
Securing interactive form fields with user-specific passwords in standard AcroForms or XFA forms.
Observed behavior
Currently, both users can lock and unlock the fields with their respective passwords. The goal state requires conditional logic to restrict the unlock action to the original locking user.
Before you start

Ensure you have access to a professional PDF editor that supports JavaScript or advanced form scripting, as basic PDF readers cannot execute conditional locking logic.

Solution 1Recommended

Use a Hidden Field and Custom JavaScript in AcroForms

This method stores the locking user's identity in a hidden field, actively verifying it before allowing an unlock action.

By utilizing a hidden text field, you can track which user (User A or User B) initiated the lock. The unlock script will then read this field to ensure the correct person is entering the password.

1
Create a hidden text field

Open your PDF form in editing mode and insert a new text field. Go to its properties and set its visibility to 'Hidden' so it does not display on the document.

2
Update the lock script

Modify the JavaScript on your 'Lock' button. When a user inputs their password to lock the fields, the script must write a unique identifier (e.g., 'A' or 'B') to the hidden text field you created.

3
Add conditional logic to the unlock script

Update the JavaScript on your 'Unlock' button to first read the value of the hidden text field. Add an 'if' condition that checks whether the stored identifier matches the current user trying to unlock the form.

4
Clear the identifier

Ensure the unlock script clears or resets the hidden text field's value once the correct user successfully unlocks the fields.

Use a Hidden Field and Custom JavaScript in AcroForms
Script Validation: Always test your JavaScript in the PDF editor's console to ensure there are no syntax errors before distributing the form.
Secure Your PDFs with WPS Office

Manage PDF Form Security and Restrictions with WPS PDF

While advanced JavaScript for user-specific locking requires professional scripting, WPS PDF provides an intuitive, code-free way to encrypt files, restrict editing, and manage document security.

  1. 1. Open the PDF file: Launch WPS Office and open the PDF document you want to secure.
  2. 2. Navigate to the Protect tab: Click on the 'Protect' tab located on the top ribbon menu to access the security tools.
  3. 3. Select Encrypt: Click the 'Encrypt' button to open the password encryption dialog box.
  4. 4. Set editing restrictions: Check the box for 'Set password to restrict editing and printing', enter a secure password, and confirm to lock the form's content securely.
Easily encrypt PDFs with strong 128-bit or 256-bit passwordsRestrict unauthorized editing, printing, and content copyingFully compatible with standard Adobe PDF formats and form fieldsCross-platform support for Windows, Mac, and mobile devices
QA img-9

Frequently Asked Questions

Can I lock individual PDF fields without using JavaScript?

Yes, you can manually set a PDF form field to 'Read-Only' in standard PDF editors like WPS PDF or Acrobat without coding. However, if you want fields to lock and unlock dynamically based on specific user passwords, custom JavaScript is required.

Does user-specific JavaScript locking work on mobile PDF readers?

In most cases, no. Custom JavaScript inside PDF forms is usually not fully supported by default mobile PDF viewers. Users will likely need to open the document in a robust desktop application to execute the scripts correctly.

What is the difference between AcroForms and XFA forms?

AcroForms are standard, widely compatible interactive PDF forms that use standard JavaScript. XFA forms are XML-based, dynamic forms created in LiveCycle Designer that offer complex layouts but require specialized software to view and execute scripts.