Copy link to clipboard
Copied
We are working on implementing digital signatures on forms due to our recent inability to meet directly with our customers. From what I read it seems I need to have a button that would unhide the digital signature field if it was checked and that would run a script to check if all of the required fields were not blank, if one was still blank it would alert the user they need to fill out all required fields. Can someone please help me with this script? I have tried but I am not able to get it to work correctly.
Copy link to clipboard
Copied
Hi,
Please share the script that you're trying to use so that the developers in the forums can assist you better.
Copy link to clipboard
Copied
Thanks for the reply, I don't think anything i had found was too helpful.
Basically any required fields blank then signature is not allowed.
Copy link to clipboard
Copied
I got the bottom to work but now I want a popup to display a message that not all required fields are filled out if they click the read only signture box otherwise it is confusing
if(event.value != "" && this.getField("Last Name").value != "" && this.getField("First Name").value != ""
&& this.getField("Street Address").value != ""
&& this.getField("City").value != ""
&& this.getField("Zip").value != ""
&& this.getField("Phone number").value != ""
&& this.getField("Date_of_Birth").value != ""
&& this.getField("Sex").value != ""
this.getField("Signature").readonly = false;
} else {
this.getField("Signature").readonly = true;
}
Copy link to clipboard
Copied
You can use this code to do it:
this.getField("Signature").readonly = !validateRequiredFields(this);
function validateRequiredFields(doc) {
var emptyFields = [];
for (var i=0; i<doc.numFields; i++) {
var f = doc.getField(doc.getNthFieldName(i));
if (f!=null && f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("You must fill in the following fields:\n" + emptyFields.join("\n"));
return false;
}
return true;
}
Copy link to clipboard
Copied
Thanks a bunch, but where exactly does this go?
Copy link to clipboard
Copied
As the Mouse Up event of your button.
Copy link to clipboard
Copied
That worked, thanks so much!
Copy link to clipboard
Copied
One small thing. It seems that this script only works on the first instance of mouseup. If I click it a second time as a user who thinks they are ready but are not actually I get no message?
Copy link to clipboard
Copied
No, that should not be the case. Can you share the file with us?
Copy link to clipboard
Copied
I can't. I will try to recreate it but it might take a day or two. I will tell you I click the digital signature box, I get the popup, then if I try to click the digital signature box again I get nothing. If I hover over the box the mouse arrow has a little box next to it like it is stuck.
Copy link to clipboard
Copied
Thank you for this! I used this script, changing the signature field name to mine (Signature_0), but when fields are missing, my signature field is set to read only and I cannot reselect it after completing the missing fields. Even when I RESET the form, the signature field remains read only - I can manually remove the read only setting, but users won't have that ability.