Javascript Mobile number Specific Mask Regex
I need Regex for mobile number to maintain the international mobile number format but without (00 or +) which means the first char开发者_开发问答acter must be a digit [1-9] and the maxlength should be 15
Example
966506863777 is correct, but (+966506863777, 00966506863777) is not correct.What you are asking is a horrible validation and user experience solution, heck you seem to be the tough coder type. So, here it is:
^[1-9][0-9]{0,14}$
A javascript validation example:
var number = '966506863777';
if (/^[1-9][0-9]{0,14}$/.test(subject)) {
alert('Valid number');
} else {
alert('Invalid number');
}
精彩评论