0

I want to validate phone number. Phone Number = countryCode+areaCode+PhoneNumber. I want to know what is the standard minimum and maximum length of Phone Number so i could validate it. -thanks

Usman Riaz
  • 2,920
  • 10
  • 43
  • 66

2 Answers2

0

Try this regex:

^[+]?[0-9]{10,13}$

Or this:

PhoneNumberUtils.isGlobalPhoneNumber("+912012185234");
GIGAMOLE
  • 1,274
  • 1
  • 11
  • 17
0

It would depend on if you are accepting any country code or are looking for specific country code/s.

Then how many digits you are expecting for area code and then the actual phone number and whether these are being fetched as separate variables or one string.

So after answering these question. You can use (test your code) regex (learn how to use it), (and as @Basil has suggested), but vary the length (and possibly digits, if there are limited country codes) accordingly.

Here is a good answer to using regex in android.

Community
  • 1
  • 1