Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Email form validation

    Hi,

    I have a form which mostly works and validates with javascript
    Name, details, email, etc.

    However the email bit is happy to validate with just @. instead of a@b.net/com/whatever.

    It's probably a really simple fix, but I'm still new to javascript..

    Hopefully someone can point out what I need to add / change in the following section of script.

    Code:
    if(form.email.value=="")
    {
      alert("Please Enter Email Address");
      return false;
    }
    if(form.email.value!="")
      {
        str=form.email.value;
        var AtTheRate= str.indexOf("@");
        var DotSap= str.lastIndexOf(".");
        if (AtTheRate==-1 || DotSap ==-1)
        {
            alert("Enter Proper Email Address");
            return false;
        }
        else
        {
           if( AtTheRate > DotSap )
           {
              alert("Enter Valid Email Address");
              return false;
           }
        }
      }
    Thankyou

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    You can guess that this has been covered many times before, so you could have used the search facility.

    For example:-

    http://www.codingforums.com/showthread.php?t=86647


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •