-1

i have a phone number inputs like:

Belgium: 0471712211 or 471712211 or 32471712211 or 0032471712211
UK: 0123456 or 123456 or 440123456 or 44123456 or 0044123456

Now i need to accept above inputs, but need to send always the number format only into this format +32471712211 or +44123456 but user can insert random formats, which is the problem.

Is there any PHP class out there for handling dialing numbers? or any other php libraries for dealing the dialing numbers?

Mihai
  • 26,325
  • 7
  • 66
  • 81
  • 2
    It'll probably be a bit hit and miss but see : http://stackoverflow.com/questions/123559/a-comprehensive-regex-for-phone-number-validation – CD001 Jan 22 '15 at 10:25
  • Is this a spammer? everytime i post a question without reading i see minus vote. –  Jan 22 '15 at 12:04

2 Answers2

0

You should use regex patterns. Add validator in application/forms/YourForm.php for field with phone number.

raz
  • 13
  • 8
  • No. I mean patterns of regular expressions. Something like: http://stackoverflow.com/questions/18119817/regex-phone-number-validation-with-php – raz Jan 22 '15 at 12:22
  • This library which you found can be good but I prefer regex because it is universal for most programming languages. – raz Jan 22 '15 at 12:24
0

Based on the country list, you can pre provided disabled textbox with country code and on phone number textbox you can bind a function which validate weather the number limit matches with that country code or not.

Semicolon
  • 1,847
  • 2
  • 15
  • 19