Creating button to check required fields
Hi!
I'm working on a form with lots of required fields. After doing some research, I've found the best way to have clients check for required fields (since they won't be submitting the document) is to have a button that says" "You missed some fields: *and pushes all unfilled and required field names*" or a message saying 'Hooray, you filled out all required fields."
Here is what I have so far in the actions, mouse up, run javascript:
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("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
}
if (!(emptyFields.length>0)) {
app.alert("All Required Fields have been answered. Thank you for filling out this form.");
}
When I added the button, it worked great! But after renaming my fields to follow tab order, the button now does not function at all. When you click it nothing happens. Please help!
