email validation that will not accept underscore after the @

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelmukhopadhya
    New Member
    • Dec 2010
    • 23

    email validation that will not accept underscore after the @

    Hi,
    all thanks in advance, i need a help immediately.

    i need to create email validation function that will accept no underscore character after the @

    Please help. its so urgent
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use a regular expression, or if you don't want to do that, you could follow this algorithm:

    Find index of the @ character.
    Substring out the character after that index.
    Check to see if it's an underscore.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      or just look if the address contains "@_".

      Comment

      • neelmukhopadhya
        New Member
        • Dec 2010
        • 23

        #4
        Code:
        function CheckEmail() {
                    var email = document.getElementById('txtEmail');
                    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/ ;
                    if (!filter.test(email.value)) {
                        alert('Please provide a valid email address');
                        return false;
                    }
                    alert('email address is Ok');
                    return true;
                }
        this is working fine for me
        Last edited by Dormilich; Jul 21 '11, 11:39 AM. Reason: please use [CODE] [/CODE] tags when posting code

        Comment

        Working...