Skip to main content
Known Participant
July 28, 2021
Question

Set fields read-only after signing with javascript

  • July 28, 2021
  • 2 replies
  • 3078 views

I have created a form with a button that adds a group of five text fields and one signature field to it. It is possible to add five groups. I want to make read-only all fields in a specific group after putting a signature in a signature field placed in the same group. Last hope in javascript because these fields don't exist until the button is pressed.

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
July 28, 2021

Do you mean that you want to use JS to set the Signed action of the signature fields to lock certain fields?

If so, you can do is using the setLock method, like this:

 

this.getField("Signature1").setLock({ action: "Include", fields: ["Text1", "Text2", "Text3"] });

 

However, the fields you specify in the fields array have to actually exist when you set the action, or it will fail.

Known Participant
July 28, 2021

I used the setLock method but it didn't work. I received an error: NotAllowedError: Security settings prevent access to this property or method. Field.setLock

I use Adobe Acrobat 2020

try67
Community Expert
Community Expert
July 28, 2021

Did you run it in Acrobat or in Reader?

This is not the kind of method that you're supposed to use dynamically. You use it once and that's it.

I don't quite understand what you're trying to achieve, exactly...

Nesa Nurani
Community Expert
Community Expert
July 28, 2021

If you want to make field read only after you signed signature field use script to make them readonly in Signed field->properties->signed tab (see photo):

Basic script to make read only:

this.getField("Field name").readonly = true;

Known Participant
July 28, 2021

I can't do it this way, because there aren't any fields on the form until the button is pressed.