开发者

validation for phone number in a form....Really Stuck

Before you start flaming or anything at all, READ THIS! I have a regular expression verifying the format of a phone number entered in a form is correct. NOW what I am hoping to find is IF someone knows a way to verify if that number exists...so if the number doesnt exist and the user enters it, user will get an error message phone number does not exist and they will be prompted to en开发者_运维百科ter a WORKINg phone number....

I have looked ALL over the seas of google but could not find a phone number validator not a format checker like regex...

This is my last hope..


In order to check if a phone number really exists (and belongs to the user who's filling your form), I see only one solution : try to communicate with that phone.

What's generally done is sending an SMS with a validation code to the phone number -- and ask the user to type that code once he has received the SMS.

This way, you'll be sure that :

  • The phone number exists,
  • And belongs to the current user.


Of course, make sure you put some security measure in place, to prevent anyone from using your form to spam some number :

  • Make sure one user cannot send more than X SMS per hour/day,
  • Make sure no more than 2 or 3 SMS can be sent to the same number per day/week


The short answer is no. You would need access to a database containing all the world's phone numbers - a sort of combined affair from the big providers. Having said that you could set up a system whereby you actually phone the number automatically and ask the user to enter a code. This would require a lot of set-up and would cost a fair bit. That is the only way you could do such a thing.

For mobile numbers you could also use SMS and require a reply.


Maybe MaxMind can help you : http://www.maxmind.com/app/telephone_overview

It provides a nice API, but its not free.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜