0

In android phone if we enter the phone number as English alphabet (eg agchge) it says invalid address. If I enter English alphabet+some numbers(eg 232as55) it accepts.

Please let me know what are the rules to check the entered phone number is acceptable by the android platform?.

Kara
  • 6,115
  • 16
  • 50
  • 57
user1123931
  • 479
  • 1
  • 8
  • 24

1 Answers1

1

May be you regular expression is in another format which does not satisfies your requirement.

so try this

 String PHN_PATTERN = "^[+]?[-)(0-9]{3,20}$";
 String strphnvalue = resPhone.getText().toString();
 if(!(strphnvalue.equals("")))
 {
   if(!(strphnvalue.matches(PHN_PATTERN))) {               
      Toast.makeText(register.this,resource.getString(R.string.validphn), Toast.LENGTH_SHORT).show();
      }
 }

Note:=>its give exact result. otherwise change this regular expression according to your requirement

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
  • My question is not related to the format of the phone number. But on how the android platform accepts and rejects the phone numbers.example it rejects "abcdef" and accepts "12abcd456" – user1123931 Jul 23 '12 at 13:25