tags:

views:

17

answers:

1

Hi,

I have an application that has records of multiple countries' users.And I am recording the phone no. of each user.And i want to apply validation on phone no country wise format.

Thanks!

A: 

Validating the format 100% will be near impossible, you will have to make some sacrifices.

I only know about UK phone numbers, but there are countless possible valid number formats, and different ways of representing them, eg:

+44 2345 123 456
02345123456
1234 56 78

your best bet would be to validate it only contains numbers and spaces, starts with a +. it could also contain a # for extensions?

some simple regex would be:

/\+?[\d+](\#\d+)?/i
Andrew Bullock