#1
  1. Trying to improve
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Helsingborg, Sweden
    Posts
    237
    Rep Power
    12

    Email jQuery validation ","


    Hey!
    I was wondering how I could force a dot (.) in a email address with regex.

    my string looks like:
    Code:
    new RegExp(/^([a-zA-Z0-9]{3,})(((\.|\-|\_)[a-zA-Z0-9]{2,})+)?@([a-z]{3,})(\-[a-z0-9]{3,})?(\.\[a-z]{2,})+$/))
    Works fine, only that I can use a email like: testing@testing,com (with a ",") and it validates as true.

    any help would be nice!
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,295
    Rep Power
    9400
    Nothing in there allows commas. What's the rest of the code?
  4. #3
  5. Trying to improve
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Location
    Helsingborg, Sweden
    Posts
    237
    Rep Power
    12
    its a jQuery thing so I dont really know.
    I call the validation with:

    Code:
    jQuery("#email").validate({
    expression: "if (VAL.match (new RegExp(/^([a-zA-Z0-9]{3,})(((\.|\-|\_)[a-zA-Z0-9]{2,})+)?@([a-z]{3,})(\-[a-z0-9]{3,})?(\.\[a-z]{2,})+$/))) 
    return true; 
    else 
    return false;",
    message: "error!"
    And the code is from: http://www.geektantra.com/2009/09/jq...n-version-1-1/
    ( I've added the '(new RegExp' and the regex itself tho) )

IMN logo majestic logo threadwatch logo seochat tools logo