Copy link to clipboard
Copied
I'm used the script below to detect unfilled fields on my forms. It works great however it can't detect unfilled drop downs they are set to be required. Any help would be greatly appreciated!
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f!=null && 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("Error! You must complete the following fields:\n" + emptyFields.join("\n"));
}
I wrote this code, but that's an old version of it. Replace this line:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
With:
if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);
Copy link to clipboard
Copied
The code checks only text fields and check boxes.
Copy link to clipboard
Copied
I wrote this code, but that's an old version of it. Replace this line:
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
With:
if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);
Copy link to clipboard
Copied
Thank you! I've been using the original code for a while now, thanks for writing it.