Skip to content
Advertisement

Mobile Number Validation (Internationally)

i am trying to do Validation check on mobile number , somewhat similar to what gmail had implemented.

Gmail signup page link

but variation among the phone number across country is to much, so finding it difficult to frame a regex for this.

i looked upon some of the q’s here , but they work for some country or a particular country, please mention if i missed.

question in SO

mainly i want to achieve what gmail has done with the mobile number.

Advertisement

Answer

In the page you provided, google uses ajax to check those e-mails. Look at the Request content:

{"input01":{"Input":"RecoveryPhoneNumber","RecoveryPhoneNumber":"+44 12345678","RecoveryPhoneCountry":"GB"},"Locale":"pl"}

My guess is they don’t have any magical universal regex – they probably have the whole database of regexes – each matching phone numbers in every country. My guess is you can do the same, but you will have to work on creating such database (if no one already did).

You can also cheat your way there and try to connect to their ajax service and make requests on your own to their checker. This would be an easy way, but really not reliable and probably not even legal.

EDIT: There are a lot of pages where you can find examples. The hard part is to gather all of the regexes.

Advertisement