Lock image fields with signature
Copy link to clipboard
Copied
Hi All,
Im currently trying to set up a PDF form where the users can insert screenshots and then sign the form. It works very well with the prepare form -> add an image field tool. If I understand correctly, this creates just a form field with the JavaScript command event.target.buttonImportIcon(). Unfortunately, I cannot find a way to lock the images trough signature. Does anybody know if there is a solution to this? Signature action -> lock all fields does not work, I still can replace the images after. If it does not work by signature, maybe there is a way that the javascript can only be run once to prevent changing the image later.
Many thanks in advance for any thoughts on this
Copy link to clipboard
Copied
It's probably because the image of a button field is not really a value, technically speaking.
However, under the Signed event of the signature field you can set the fields as read-only, which will prevent the user from editing them.
The code to do so is the following:
for (var i=0; i<this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (f==null) continue;
f.readonly = true;
}
Copy link to clipboard
Copied
Hi,
thank you very much for your quick reply. Unfortunately, this locks all fields, but the image fields still work. I now added an if statement to check that the signature field has not been signed before executing the java command to update the field icon. This works pretty good so far:
if (getField("Signature1").value == "")
{event.target.buttonImportIcon();}
Best regards,
Tobias
Copy link to clipboard
Copied
That's not possible. If the field is set as read-only clicking it will do nothing.
But your solution works too!
Copy link to clipboard
Copied
So far it works very well.
But maybe there is another thing that would be really helpful. Is there a way to adapt your code to only lock fields that contain a certain string? For example "fname" contains "_part1".
I use forms with multiple parts where a signature only locks this specific part. Picking the fields manually is not very efficient.
Copy link to clipboard
Copied
Sure.
Before this line:
f.readonly = true;
Add this:
if (/_part1/.test(fname))

