How to Lock PDF Form Fields So Only the Correct User Can Unlock Them
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.

- 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.
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.
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.
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.
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.
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.
Ensure the unlock script clears or resets the hidden text field's value once the correct user successfully unlocks the fields.

Apply Conditional Logic in LiveCycle Designer for XFA Forms
If you are using XML-based XFA forms, use LiveCycle Designer's built-in scripting to handle the conditional locking logic.
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. Open the PDF file: Launch WPS Office and open the PDF document you want to secure.
- 2. Navigate to the Protect tab: Click on the 'Protect' tab located on the top ribbon menu to access the security tools.
- 3. Select Encrypt: Click the 'Encrypt' button to open the password encryption dialog box.
- 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.

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.




