Function checkmobile (){
VaR Tel = $ ('. tel'). Val ();
VaR MSG = $ ('# msg_tel ');
/*
"/" Represents a regular expression.
"^" Indicates the start position of the string, and "$" indicates the end position of the string.
"?" It indicates matching one or zero characters before, so here 0? The mobile phone number can start with 0 or not.
Next, verify the 11-digit mobile phone number starting from 13. The range is [0-9] Because the 11-digit mobile phone number is available from 130-139. the number starting with 15 is not 154, so [] does not contain the number 4. Of course, it can also be written as [0-35-9]. The numbers listed in the 18 and 14 below are the same as those listed in the preceding figure.
Enclosed in parentheses represents a subexpression, which contains four optional branches separated by "|". In regular expressions, "|" has the lowest priority, here, each branch matches three characters (one [] can only match one character, which is optional), that is, the first three digits of the mobile phone number, then there are 8 digits to be matched, which can be any 0-9 character. Therefore, the value is "[0-9] {8}", and the number in {} indicates the number that matches the previous character. The analysis is complete.
*/
VaR regu =/^ 0? (13 [0-9] | 15 [012356789] | 18 [0236789] | 14 [57]) [0-9] {8} $ /;
VaR Re = new Regexp (regu );
If (Re. Test (TEL )){
MSG. removeclass ('msgtel ');
MSG. addclass ('msg ');
Return true;
} Else {
MSG. removeclass ('msg ');
MSG. addclass ('msgtel ');
Return false;
}
}