Bulvak
Bulvak

Reputation: 1804

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 enter 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..

Upvotes: 1

Views: 269

Answers (3)

Maxime Fafard
Maxime Fafard

Reputation: 376

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

It provides a nice API, but its not free.

Upvotes: 0

Tom Walters
Tom Walters

Reputation: 15616

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.

Upvotes: 1

Pascal MARTIN
Pascal MARTIN

Reputation: 401032

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

Upvotes: 3

Related Questions