Hello everybody,
I have a form that when the submit button is selected, it checks that certain fields in the form are filled in (works great!) A section of the form is associated to a checkbox. Now this is what I am looking to do. If the check box is not checked those fields associated to the checkbox is not validated, but when checked, I want those fields to verify they are not empty upon the selection of the submit button.
Now I am not getting any errors, but it is not checking the fields when the checkbox is selected.
Can someone help?
Thanks in advance.
[code]
Script Code:
function ValidateForm1(theForm) {
if (theForm.ServiceSelect.checked = true){
if (theForm.EAddress.value == “Null”){
alert(“Please enter your Event Address”);
theForm.EAddress.focus();
return false;
}
if (theForm.EAddress.value.length < 1){
alert(“Please enter your Event Address”);
theForm.EAddress.focus();
return false;
}
if (theForm.ECity.value == “”) {
alert(“Please enter the City your Event will take place”);
theForm.ECity.focus();
return false;
}
if (theForm.ECity.value.length < 1) {
alert(“Please enter the City your Event will take place”);
theForm.ECity.focus();
return false;
}
if (theForm.EState.value == “Null”) {
alert(“Please select the state your event will take place”);
theForm.EState.focus();
return false;
}
if (theForm.EState.value.length < 1){
alert(“Please select the state your event will take place”);
theForm.EState.focus();
return false;
}
if (theForm.EZip.value == “”){
alert(“Please enter the Zip Code your Event will take place”);
theForm.EZip.focus();
return false;
}
if (theForm.EZip.value.length < 5){
alert(“Please enter the Zip Code your Event will take place”);
theForm.EZip.focus();
return false;
}
HTML CODE:
<INPUT TYPE=”checkbox” NAME=”ServiceSelect” ID=”SS” onclick=”EnableEventAddress()”><FONT SIZE=”4″ COLOR=”#5F2C52″><B>Check if you are interested in the <A HREF=”./price.asp#Service”>Extended Service</B></A></FONT></TD></TR>
<TR>
<TD>
<FONT SIZE=”2″ COLOR=”#5F2C52″>Event Address:</FONT></TD>
<TD>
<INPUT TYPE=”text” NAME=”Ga_Event_Address” Size=”45″ ID=”EAddress” disabled=”disabled”></TD></TR>
<TR>
<TD>
<FONT SIZE=”2″ COLOR=”#5F2C52″>City:</FONT></TD>
<TD>
<INPUT TYPE=”text” Name=”Gb_Event_City” size=”10″ ID=”ECity” disabled=”disabled”></TD></TR>
<TR>
<TD>
<FONT SIZE=”2″ COLOR=”#5F2C52″>State:</FONT></TD>
<TD>
<SELECT NAME=”Gc_Event_State” Size=”1″ ID=”EState” disabled=”disabled”>
<OPTION VALUE=”Null”>Select</OPTION SELECTED>
<option value=”DC”>D.C</option>
<option value=”MD”>Maryland</option>
<option value=”VA”>Viriginia</option>
</SELECT></TD></TR>
<TR>
<TD>
<FONT SIZE=”2″ COLOR=”#5F2C52″>Zip:</FONT></TD>
<TD>
<INPUT TYPE=”text” NAME=”Gd_Event_ZIP” size=”10″ maxlength=”5″ ID=”EZip” disabled=”disabled”></TD></TR>