Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Validation

Status
Not open for further replies.

glenmac

Technical User
Jul 3, 2002
947
CA
Hi got an issue with my script and FF. I use the folowing code for validation but it doesn't work for me using FF, works fine with IE.
Code:
function checkemail() {
var check = document.form
var one = new Array("com", "edu", "net", "ca", "org")

  if(check.email.value == "") {
    alert("Please enter your email address");
    check.email.focus();
    return false;
  }
  if(check.email.value.indexOf("@") == -1 || check.email.value.lastIndexOf(".") == -1)  {
    alert("Error in EMail Address");
    check.email.select();
    return false;
  }
 var bOK = false;
  for(i=0; i<=one.length; i++) {
    if(check.email.value.indexOf("." + one[i]) > -1) {
      bOK = true;
    }
  }
  if (!bOK) {
    alert("Error in EMail Address");
    check.email.select();
    return false;
  }
if(check.email.value.indexOf("@") < 2) {
    alert("Error in EMail Address");
    check.email.selecy();
    return false;
}
     document.getElementById('test1').style.display='none';
     document.getElementById('thankyou').style.display='block';

}{/code]
the form is written like this;
[code]
<div id = "test1" align = "center"> <h2> Enter your Email Address for a <span style = "color:orange;">Free Clinic Draw</span> </h2>

<form name="form"  method="post" action = "mailto:draw@ezrasoccer.com?subject=Free draw" onSubmit="return checkemail();">
    <input type="text" name="email"><br><br>
    <input type="submit" name="Submit" value="Enter Draw">
</form>
</div>
<div  align ="center" id='thankyou' style="display:none; color:red; font-size:larger;">
Your Email Address Has Been Entered.<br/>
Good Luck!!
</div>
All help is appreciated!

Glen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top