Copy link to clipboard
Copied
Hello everyone, I have the following problem.
The signature field may only be writable when text1 and checkbox1 are filled in. If not, the message should appear which text/boxes are not yet filled in. Only then can the e-signature be set. I have found this code. The message appears, but it can be confirmed with ok and it is still possible to set the signature. In addition, all required fields are queried. However, only text1 and checkbox1 are to be queried as to whether they are filled. Can someone please help me? Thank you very much.
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("Bitte noch folgende felder ausfüllen:\n" + emptyFields.join("\n"));
return false;
}
return true;
}
Copy link to clipboard
Copied
Hi,
I have not checked the code, but what if you made the field hidden and then show it when the fields are filled in, you could hide it again if they are changed to be blank, this would mean that the user cannot sign the document until they have done what you required.
I would recommend moving the script to the validate event of the fields that you are wanting to be filled in.