Email Validation Script

Discussion in 'JavaScript' started by sellerscentral, Nov 6, 2011.

  1. #1
    I have a question. My site generates email addresses for registered users. The email addresses look like this "John265Green@top.MYSITE.com" Can you please show me how to make email verification javascript for the following format

    1) All entered email addresses must contain "@top.www.MYSITE.com"

    2) The first part of the email address must be "(LETTERS)(3 Numbers)(LETTERS)@top.www.MYSITE.com"

    Thanks in advance for the help guys. I truly appreciate it!
     
    sellerscentral, Nov 6, 2011 IP
  2. dixcoder

    dixcoder Member

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #2
    I hope the following regular expression works for you :)

    \w*\d{3}\w*\@top\.www\.MYSITE\.com
     
    dixcoder, Nov 7, 2011 IP
  3. sellerscentral

    sellerscentral Well-Known Member

    Messages:
    1,631
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    158
    #3

    Can you please include to full function javascript and input form to call it? Maybe an alert box saying "invalid" if they input the wrong email type? That way can just copy and paste it in my php file? Otherwise I am lost. Thanks dixcoder and anyone else who wants to have a shot at it!
     
    sellerscentral, Nov 7, 2011 IP
  4. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #4
    
    <script type="text/javascript">
    
    if(/\w*\d{3}\w*\@top\.www\.MYSITE\.com/.test(email_text))
     alert("valid email");
    
    </script>
    
    HTML:
     
    JohnnySchultz, Nov 23, 2011 IP