regex - How to validate mobile number in Regular Expression -
i trying validate mobile using regular expression
so have tried https://regex101.com/#javascript
my expresion ((\d[^0-5]|[6-9])\d{9})|^(\d)\1*$
i need validate moblie number below
1.it should not start 0-5
e.g 0600432102
2.not same or in sequence
e.g 1111111111 or 0123456789 or 9876543210
3.lenght 10 digit
where made error.
help me....
thanks ....
this covers criteria , tests few numbers. not specify reason number being invalid - leave you.
var numarr = ["1111111111", "0123456789", "9876543210", "8682375827", "83255"]; (var = 0; < numarr.length; i++) { console.log(numarr[i] + " " + validate(numarr[i])); } function validate(num) { if ((num.match(/^[6-9]\d{9}$/) && (!num.match(/^([0-9])\1{9}$/))) && (!isincr(num) && (!isdecr(num)))) { return ( "valid") ; } else { return ( "not valid") ; } } function isincr(num) { (var = 1; < num.length; i++) { if (num[i] == parseint(num[i - 1]) + 1) { continue; } else { return false; } } return true; } function isdecr(num) { (var = 1; < num.length; i++) { if (num[i] == parseint(num[i - 1]) - 1) { continue; } else { return false; } } return true; }
Comments
Post a Comment