Lock and Unlock LiveCycle PDF Form Fields with JavaScript
Question details
The user wants to prevent recipients from changing completed fields in a LiveCycle Designer PDF form.

- Product
- Adobe LiveCycle Designer
- Device & OS
- not provided
- Scenario
- A form designer wants to lock completed fields and, if needed, unlock them using form scripting.
- Observed behavior
- Completed fields should become read-only while the form remains usable for its intended workflow.
Open the source form in LiveCycle Designer and identify the fields and controls that will trigger locking or unlocking. Test the saved form in a PDF viewer that supports XFA forms and JavaScript; browser PDF viewers may not run the scripts.
Set LiveCycle form fields to read-only with JavaScript
Use form scripting to control whether a field can be edited during a supported PDF form session.
This is a user-interface control, not reliable security. A recipient who can trigger the unlock script or modify the form with specialized tools may be able to change the data.
In LiveCycle Designer, open the form and select the button or other object that should lock the completed field.
Open the Script Editor, select an appropriate event such as the button's click event, and set the script language to JavaScript with execution on the client.
Enter a script such as xfa.resolveNode("form1.Page1.CustomerName").access = "readOnly"; and replace the example path with the target field's actual XFA path. Add a line for each field you want to lock.
For a separate unlock button's click event, use the same field path with access = "open". Do not expose this control to recipients if they should not be able to unlock the field.
Save the form as a PDF, open it in an XFA-compatible viewer, complete the field, and use the controls to verify that locking and unlocking work as expected.

Apply PDF editing restrictions after the form is finalized
Use a permissions password when recipients no longer need to edit the completed form.
Work with everyday documents and PDFs in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with common Office documents and PDFs. Its format compatibility helps you move existing files into a new workflow. It does not replace LiveCycle Designer for creating or controlling XFA form scripts, so check form compatibility before sharing.

Frequently Asked Questions
Can JavaScript make a LiveCycle form field read-only?
Yes. In LiveCycle Designer's Script Editor, set the target field's XFA access property to "readOnly" from an appropriate event, such as a button click.
How do I make a locked field editable again?
In an unlock control's JavaScript event, set the same field's access property to "open". Anyone who can use that control may be able to unlock the field.
Why doesn't the lock button work in a browser PDF viewer?
Many browser viewers do not support XFA forms or their JavaScript. Open the PDF in an XFA-compatible viewer and test the button there.
Does an editing password guarantee that completed fields cannot be changed?
No. PDF editing permissions can be bypassed by specialized tools. For critical integrity requirements, consider a digital signature or a managed document-control workflow.




