Im having difficulties with a small validation script. I have a group of two radio buttons (radio group called housing) and depending on what radio it tries to validate if a checbox has been selected within the group. Here is my HTML:
[B]
<form action=”registrationconfirmation.htm ” name=”frmCSC” method=”post” onsubmit=”return validForm(this)”>
<p>Housing Family
<input name=”housing” type=”radio” value=”single” “onclick=”getTotal();” />
1
<input name=”familydate21″ type=”checkbox” id=”familydate21″ value=”Y” onclick=”getTotal();” />
2
<input name=”familydate22″ type=”checkbox” id=”familydate22″ value=”Y” onclick=”getTotal();” />
3
<input name=”familydate23″ type=”checkbox” id=”familydate23″ value=”Y” onclick=”getTotal();” />
</p>
<p>Housing Single
<input name=”housing” type=”radio” value=”family” onclick=”getTotal();” />
1
<input name=”singledate21″ type=”checkbox” id=”singledate21″ value=”Y” onclick=”getTotal();” />
2
<input name=”singledate22″ type=”checkbox” id=”singledate22″ value=”Y” onclick=”getTotal();” />
3
<input name=”singledate23″ type=”checkbox” id=”singledate23″ value=”Y” onclick=”getTotal();” />
</p>
<p>
<input type=”submit” name=”Submit” value=”Submit” />
</p>
And here is the javascript i wrote but it is not validating..any suggestions?
[B]
if(theForm.housing[1].checked = true) {
if((theForm.familydate21.checked == false) && (theForm.familydate22.checked == false) && (theForm.familydate23.checked == false))
{
alert(“Please choose at least one option from the ‘Family housing’ section.”);
theForm.familydate21.focus();
return (false);
}
}
if(theForm.housing[0].checked = true) {
if((theForm.singledate21.checked == false) && (theForm.singledate22.checked == false) && (theForm.singledate23.checked == false))
{
alert(“Please choose at least one option from the ‘Single housing’ section.”);
theForm.singledate21.focus();
return (false);
}
}
[/B]
anyone know where im going wrong here? thanks you guys!