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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Florida, USA
    Posts
    275
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Phone form validification question aimed to canadians

    Hey, I found this php phone number verification script, and would like to know if this would work for canadian users as well. Since I don't personally know anyone in Canada I can't call them up to ask, and even if I could, they prob wouldnt know if it would work. So I came to ask you .

    Anyways the script is :
    PHP Code:
    function VALIDATE_USPHONE($phonenumber,$useareacode=true)
    {
    if ( 
    preg_match("/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/",$phonenumber) || (preg_match("/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/",$phonenumber) && !$useareacode)) return eregi_replace("[^0-9]"""$phonenumber);
    return 
    false;

    and was found here , The site says "US numbers" however I don't know if it can work for both.

    Thanks for your help guys

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've lived in canada before and by the looks of that regex it's just checking for numbers.. which doesn't mean it is necessarily a 'valid' phone number and since candada's phone number formatting is the same as the US' it should work.

  • #3
    Regular Coder
    Join Date
    Feb 2004
    Location
    Florida, USA
    Posts
    275
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect thank you


  •  

    Posting Permissions

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