I have a generic phone number validation function that currently validates all global phone numbers. I wanted to update it so that it only validates US phone numbers. But the problem with that is currently even if i set my phone number length to 10, it will stop short at exactly 10 characters. my users may enter something like a space or a ( ,for example : "(444)444 4444 , which wont work if i limit the number of chars to 10 even if its a valid number.Any ideas how to go about it? here's my function :
public static boolean isValidPhoneNumber(String phoneNumber) {
return !TextUtils.isEmpty(phoneNumber) && android.util.Patterns.PHONE.matcher(phoneNumber).matches() && PhoneNumberUtils.;
}