Skip to main content
Participant
May 8, 2023
Answered

Lock fields and hide fields with digital signature

  • May 8, 2023
  • 1 reply
  • 1732 views

I am using Acrobat Pro 2020. I have a document that needs to set as read-only (lock? it needs to make the fields un-editable) all of it's fields except a second signature field once the first signature field is signed. I was using the built-in functionality to "Mark as read-only: All fields except these" and then listing the second signature field. This method was working fine but now I must add a drop down field ("DD1") that once an item is selected, it auto-populates two other drop-down fields ("DD2" and "DD3"). What I would like to happen is when the first signature field is signed, all of the fields except the second signature block become read-only, and the first drop-down field ("DD1") becomes hidden. The PDF is never actaully printed, it's only used digitally, so that's why using the field property "Form Field: Visible/Hidden/Visible but doesn't print/Hidden but printable" won't suffice.

From my understanding, I have to use a script that marks the fields as read-only and sets "DD1" to hidden because I can only select one option for what happens when the first signature field is signed. Any help with figuring a script like that out would be really helpful!!

This topic has been closed for replies.
Correct answer try67

Yes, you will need to use a script to do it, and while it can't actually lock the fields, it can set them as read-only.

You can use the following code for that:

 

this.getField("DD1").display = display.hidden;
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.name=="Signature2") continue; // Do not "lock" the other signature field
	f.readonly = true;
}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 8, 2023

Yes, you will need to use a script to do it, and while it can't actually lock the fields, it can set them as read-only.

You can use the following code for that:

 

this.getField("DD1").display = display.hidden;
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.name=="Signature2") continue; // Do not "lock" the other signature field
	f.readonly = true;
}
Participant
May 8, 2023

This worked PERFECTLY. Thank you so much. I spent so much time trying to jerry-rig a script to try and do what I wanted.