Copy link to clipboard
Copied
Currently working on a script for the verify empty fields before printing to give a warning.
what i purloined and modified from the forum was
// check for empty fields
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.value==" ")) || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Important - You must fill in the following fields or your reimburstment will be delayed:\n" + emptyFields.join("\n"));
} else this.print();
I need to add for it to check combo boxes for the answer "-" as that the default setting or empty setting. Is that possible?
One can also use the "defautlValue" property of a field to check for an uncompleted field.
// check for empty fields
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.defaultValue) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Important - You must fill in the following fields or your reimburstment will be delayed:\n" + emptyFields.join("\n"));
} else this.p
...Copy link to clipboard
Copied
Change this part:
if ((f.type=="text" && (f.value=="" || f.value==" ")) || (f.type=="checkbox" && f.value=="Off"))
To:
if (f.valueAsString==f.defaultValue)
Copy link to clipboard
Copied
One can also use the "defautlValue" property of a field to check for an uncompleted field.
// check for empty fields
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.defaultValue) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Important - You must fill in the following fields or your reimburstment will be delayed:\n" + emptyFields.join("\n"));
} else this.print();
You may have to adjust your code if there is a signature field.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now