/    Sign up×
Community /Pin to ProfileBookmark

Validating Form Fields

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>[/code]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Silverado spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...