Regular Expressions: The meaning of "^[\u4e00-\u9fa5]{0,}$", "/^[\u4e00-\u9fa5]{1,5}$/":
In JS, \uxxxx is the escape character, "XXXX" corresponds to the 16 Unicode encoding;
^ matches the start of a row. For example, the regular expression ^123 can match the beginning of the string "12345", but cannot match "012345";
[\u4e00-\u9fa5] refers to a match between these two Unicode encoding characters;
{0,} repeat 0 to infinity;
$ ends with it, as 123$ is only matched with 123 end. 1234 does not match.
That is, a string that matches any character that \u4e00-\u9fa5 between two characters (which can be more than 1 characters) and that there are no other characters before or after the string.
Typical applications:
1$(function(){2 //Verify Contacts3$ (' input[name= ' Contacts "]). Focus (function(){4$( This). Next (). Text (' only supports Chinese characters ');5}). blur (function(){6 varPattern =/^[\u4e00-\u9fa5]{1,5}$/;7 if(Pattern.test ($ ( This). Val ())) {//Use the native JS test () function to match the passed-in value and return a Boolean value. 8$( This). Removeclass (' Input_err ');9$( This). Next (). Text (' √ '). Removeclass (' Txt_err '). addclass (' Txt_correct ').);TenIstrue=true; One}Else{ A$( This). addclass (' Input_err '); -$( This). Next (). Text ("X"). Removeclass (' Txt_correct '). addclass (' Txt_err ').); - } the }); - - //Verify your phone number -$ (' input[name= ' Tel "]). Focus (function(){ +$( This). Next (). Text (' Landline, use-separate ')); -}). blur (function(){ + varPattern =/^1\d{10}$|^ (0\d{2,3}-?| \ (0\d{2,3}\))? [1-9]\d{4,7} (-\d{1,8})? $/; A if(Pattern.test ($ ( This). Val () )) { at$( This). Removeclass (' Input_err '); -$( This). Next (). Text (' √ '). Removeclass (' Txt_err '). addclass (' Txt_correct ').); -Istrue=true; -}Else{ -$( This). addclass (' Input_err '); -$( This). Next (). Text ("X"). Removeclass (' Txt_correct '). addclass (' Txt_err ').); inIstrue=false; - } to }); +})
Js_ Regular Expression _ validation Chinese characters