Copy link to clipboard
Copied
Hello,
for a form i added a print button, on it is a javascript. Only when I click on the button I get the error message that several required fields have to be filled in, but the printing process starts anyway.
What I have wrong with the code?
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Bitte füllen Sie noch folgende/s Pflichtfeld/er aus, bevor Sie das Formular drucken können:\n" + emptyFields.join("\n"));
}
You have to do it all in your code. Remove the separate print command and add this to the end of your code:
else this.print();
Copy link to clipboard
Copied
You have to do it all in your code. Remove the separate print command and add this to the end of your code:
else this.print();