I have a form that if [B]I hit submit it automatically goes to the Thank You/Confirmation page without me fixing the errors
[CODE]
<script type=”text/javascript”>
function setReadOnly(style1,style2) {
document.getElementById(“USmail”).disabled=style2;
document.getElementById(“email”).disabled=style1;
}
function validateForm() {
email=document.getElementById(“email”);
USmail=document.getElementById(“USmail”);
gnum=document.getElementById(“gnumber”);
errors=0
if (email.disabled==false){
if (email.value==””){
alert(“please enter an email address”)
errors++
}
p=email.value.indexOf(‘@’);
if (p<1 || p==(email.value.length-1)) {
alert(“please enter a valid email address”)
errors++
}
}
if ((gnum.value.match(/[^0-9]/g))||(gnum.value==””)){
alert(“please enter a valid Group Number”)
errors++
}
if (document.getElementById(“ContactName”).value==””){
alert(“please enter a contact name”)
errors++
}
if (USmail.value==””&&USmail.disabled==false){
alert(“please enter a valid address”)
errors++
}
if (errors==0) {
alert(‘submit form!’)
}
}
</script>
<form id=”cform” class=”form” method=”post” action=”/cform.php”>
<input type=”hidden” name=”settings” value=”/form.php”>
<div>
<div class=”field”>
<p><label for=”gnumber” class=”label”>Group Number<span class=”asterisk”>*</span></label>
<input type=”text” class=”input” name=”gnumber” id=”gnumber” /></p>
</div>
<div class=”field”>
<p><label for=”ContactName” class=”label”>Contact Name<span class=”asterisk”>*</span></label>
<input type=”text” class=”input” name=”ContactName” id=”ContactName” /></p>
</div>
<!–Radio===================–>
<div class=”field”>
<input type=”radio” name=”email” value=”1″ id=”emailrad” checked=”checked” onclick=”setReadOnly(false,true)” />
E-mail (please enter your e-mail address): <input type=”text” class=”input” name=”email” id=”email” /><br /><br />
<input type=”radio” name=”email” value=”2″ id=”usmailrad” onclick=”setReadOnly(true,false)” />
US Mail (please enter your mailing address) <input type=”text” class=”input” disabled=”true” name=”USmail” id=”USmail” />
</div>
<!–Radio===================–>
</div>
<!–Submit–>
<div>
<input name=”submit” type=”submit” value=”Submit” onClick=”validateForm()” />
</div>
<!–Submit–>
</form>
Thanks in advanced.