Sort fields in app.alert by tab order rather than alphabetically
Hi there,
I found previously a lot of answers in many of the posts here. I am stuck a bit however and post my first post, hoping for some help from the experts.
The code below works perfectly as required and checks for any 'required' fields which have been missed. The app.alert is listing the fields requiring completion in alphabetical order.
Here is the issue: The set.Focus() part then takes the user back to the first field requiring completing. This again is in alphabetical order. I would like the user to be taken back to focus on the first field requiring completion based on tab order. Is this possible?
Any help would be greatly appreciated.
Thanks in advance.
//Check for required fields are not empty. IF ok, SaveAs
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("Oops! Please fill in all mandatory fields. \n > following field(s) need to be completed:\n\n" + emptyFields.join("\n"));
getField(emptyFields[0]).setFocus();}
else
app.execMenuItem("SaveAs");
