email and phone number validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajaymohank
    New Member
    • Jan 2008
    • 29

    email and phone number validation

    Hello friends........ ....

    i am trying to get a validation for email and phone number. in my php project i am doing the validation using java script. but i am not getting validations for email and phone number correctly...

    please give a solution for this..
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Originally posted by ajaymohank
    Hello friends........ ....

    i am trying to get a validation for email and phone number. in my php project i am doing the validation using java script. but i am not getting validations for email and phone number correctly...

    please give a solution for this..
    tell us what your javascript looks like, usually you can change the same regex implemented in PHP.

    post your js validations and i'll help you convert them to PHP.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Found some routines I use:

      Matching US phone numbers in the following formats:

      ###-###-####
      (###) ###-####
      ##########

      Restricts area codes to >= 200 and exchanges to >= 100, since values below these are invalid.[php]$pattern = "/(\([2-9]\d{2}\)\s?|[2-9]\d{2}-|[2-9]\d{2})"
      . "[1-9]\d{2}"
      . "-?\d{4}/";[/php]
      US zip pattern 5 digits (01234) or 5 digits + 4 (01234-1234)
      [php]$pattern = '^[0-9]{5}([- /]?[0-9]{4})?$^';[/php]

      Email verification[php]if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $email)) [/php]

      Ronald

      Comment

      Working...