I'm having this validation which I intent to check whether one of the two (2) checkboxes are not checked accordingly. What I mean is I have an array of checkboxes namely idLoc_(x), and for each of the idLoc_(x), I included another array of checkboxes namely channelNo_, now I want to make sure user must check BOTH sides or NEITHER one of the sides for the form to submit. If idLoc checked and ChannelNo is not checked or the other way around, alert will be acquired and correction must be made before the form can be processed. That's all!!!
So far, I got the problem when the form continue to submit after alert was popped up, and here is the code
Thanks!
So far, I got the problem when the form continue to submit after alert was popped up, and here is the code
Code:
for (x=0;x<=document.forms["edit"].elements["lCount"].value;x++)
{
if ((document.forms["edit"].elements["idLoc_" + x].value != "") && (document.forms["edit"].elements["channelNo_" + x].value == ""))
{
alert("Channel has not been selected! Please make your selection and Submit again.")
return false;
}
else if ((document.forms["edit"].elements["idLoc_" + x].value == "") && (document.forms["edit"].elements["channelNo_" + x].value != ""))
{
alert("Location for selected channel(s) has not been checked! Please review your selection and Submit again.")
return false;
}
}
return true
Thanks!