The number of mobile phone numbers is now in the following categories, including the new Three (166,199,198) issued in 17.
In some projects registered login or other, involving mobile phone number for a simple validation, in front of a simple test;
Determine if a string matches a cell phone number format
Mobile Number segment: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188,198
China Unicom: 130,131,132,145,155,156,166,170,171,175,176,185,186
Electrical Signal Segment: 133,149,153,170,173,177,180,181,189,199
The code is as follows:
1 functionphoneverify (str) {2 3 varReg =/^ ((13\d) | ( 14[5,7,9]) | (15[0-3,5-9]) | (166) | (17[0,1,3,5,7,8]) | (18[0-9]) | (19[8,9])) \d{8}/;4 5 if(Reg.test (str)) {6 return true;7}Else{8 return false;9 }Ten}
Knock on the blackboard!!
var reg =/^ ((13\d) | ( 14[5,7,9]) | (15[0-3,5-9]) | (166) | (17[0,1,3,5,7,8]) | (18[0-9]) | (19[8,9])) \d{8}/;
Over here:
- ^: Represents the Beginning
- : The portion of the red box represents the first three-bit field of the matched cell phone number, for example (14[5,6,7]) that matches the 145/146/147 segment;[0-9] and \d represent the same meaning that matches a numeric character
- This means matching a numeric character, looping 8 times
As for some other verification to be more ...
If there is anything wrong, please leave a message and make progress together.
respect for the original: reprint please enclose the source https://www.cnblogs.com/lshdashi/p/9431850.html
JS mobile phone number simple regular check