I'm stuck at a point. I need to validate a phone number by preventing below formats. For now I've applied the 10 digits validation but below formats are not correct.
0000000000
1111111111
2222222222
3333333333
4444444444
5555555555
6666666666
7777777777
8888888888
9999999999
also I need to avoid those numbers which are starting with either 1
or 0
. Like validation should avoid below formats as well.
1xxxxxxxxx
0xxxxxxxxx
Can anyone suggest me a way of doing that ?
You may try this.
^(?!(\d)\1{9}$)[2-9]\d{9}$
(?!(.)\1{9}$)
won't be the same digit which repeats exactly 10 times.[2-9]
must starts with 2 or 3 or upto 9.\d{9}
any 9 digits.$
line end.DEMO
or
^([2-9])(?!\1{9}$)\d{9}$
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With