-4

In my application there is a field called Land Line number, I want to restrict the user not to enter all zeros like "0000000000" but he can enter like "0123467889"."0801234567","98001245780" Starting zero and iin any position zero is acceptable, but not all zeros

Nandu
  • 1
  • 3

1 Answers1

0

This should do it,

private boolean isNumberValid(String number){
    return Pattern.matches("^[0-9][1-9]{9}$", number);
}
Aneeb Khawar
  • 330
  • 1
  • 8
  • it is not allowing all zeros, its fine, but it is not allowing zero any place of 10 digit num, My requirement is, not to allow all zeros But it can accept a ph num like 0801234567 etc., – Nandu Sep 22 '16 at 05:04
  • I dont think a regex alone can fulfill this requirement then. You need something like this stackoverflow.com/a/15644461/1134197. – Aneeb Khawar Sep 22 '16 at 05:11
  • Try this as well, android.util.Patterns.PHONE.matcher(number).matches(); – Aneeb Khawar Sep 22 '16 at 05:13