LewisReeder
IS-IT--Management
I am fairly new to javascript so I am sure the answer is simply, but when I run this function it only runs through the first IF statement and stops. I have tested this with an alert() window. When the user clicks the submit button I want to validate that each field was completed. Could someone please tell me what I am doing wrong?
function submitClick(strSubmit)
{
var boolError = false, strError = "";
var frm = document.frmTSC, boolAccount, boolJustification;
if(frm.tbxSatFrom.value == "")
{ boolError = true;
strError += "\nMissing...";
}
if(frm.tbxSunFrom.value == "")
{ boolError = true;
strError += "\nMissing...";
}
// Set the submit flag
frm.tbxSubmit.value = strSubmit;
if (boolError) {
alert("Data Validation Errors\n" + strError);
}
else {
// Submit the form
frm.submit();
}
}
//(button click)
input type="submit" value="Submit" onClick="javascript:submitClick('N');">
Thanks,
Lewis
function submitClick(strSubmit)
{
var boolError = false, strError = "";
var frm = document.frmTSC, boolAccount, boolJustification;
if(frm.tbxSatFrom.value == "")
{ boolError = true;
strError += "\nMissing...";
}
if(frm.tbxSunFrom.value == "")
{ boolError = true;
strError += "\nMissing...";
}
// Set the submit flag
frm.tbxSubmit.value = strSubmit;
if (boolError) {
alert("Data Validation Errors\n" + strError);
}
else {
// Submit the form
frm.submit();
}
}
//(button click)
input type="submit" value="Submit" onClick="javascript:submitClick('N');">
Thanks,
Lewis