Submit button check if all the required fields are filled in and lock them
Good evening,
I'm trying to program a Submit button, in one click it should check that the required fields are filled in (Except for some of them) and lock them once it's correct.
I'm posting my code, not sure what I'm doing wrong. Probably everything.
var nButton = app.alert ("Are you sure you want to submit the Staging Pre-Configuration Request? After submission the form won't be editable.",1,2);
if (nButton == 4){
var aExcept = [ "Stag_Comm", "Ret_Date_af_date", "Sta_Name", "Sta_Sign", "Sta_submit", "Remove Page", "Add Page", "Pic_1_af_image", "Pic_2_af_image", "Remove Page Template", "Add Page Template", "Pic_1 Template_af_image", "Pic_2 Template_af_image" ];
for (var i=0; i<this.numFields; i++)
{var name = this.getNthFieldName(i);
{if (aExcept.indexOf(name) == -1)
{var f = this.getField(name);
var emptyFields = [];
if (f.type!="button" && f.required && f.value == f.defaultValue) {emptyFields.push(f.name);}
if (emptyFields.length>0)
{app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));}
else
{if (f != null)
{f.readonly = true;
}
}
}
for(var i = this.numFields - 1; i > -1; i--)
{
this.getField("Req_submit").display=display.hidden;
}
}
}
}
else
{app.execMenuItem("Save")}
