function checkMandatory(){ var flag = true; var message = 'Please fill in all mandatory fields !'; if (document.checkFRM.field2.value.length==0){ flag = false; }; if (document.checkFRM.field3.value.length==0){ flag = false; }; if (document.checkFRM.field4.value.length==0){ flag = false; }; if (document.checkFRM.field5.value.length==0){ flag = false; }; if (flag == false) { alert(message); }; return flag; };