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 Coder
    Join Date
    Jan 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to do email vaildation in javascript?

    How do you create in javascript to do email vaildation? to check

    must contain 1 @
    must contain 1 letter before the @
    must contain 1 letter after the @
    must not contain spaces, slash, colon, comma or semicolon

    if the any of the rules are wrong it will alert the user saying "Invalid Email"

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,917
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Your conditions are not sufficient to validate an email address.

    A proper and complete email validation is:-

    Code:
    if (!(/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i.test(emailAddress.value))) {   
    alert ("Invalid email address");
    return false;

    Tourist in Athens to tour guide: "You have told us something about Byzantine architecture. Would it be possible to meet some Byzants?"


  •  

    Posting Permissions

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