Current location - Education and Training Encyclopedia - Resume - How to use regular expressions to judge whether the input name is legal (Chinese, 2-7 Chinese characters)
How to use regular expressions to judge whether the input name is legal (Chinese, 2-7 Chinese characters)
The function is in Chinese ()

{

var str = document . all . real name . value;

reg=/^([\u4e00-\u9fa5]){2,7}$/; //can only be in Chinese, with a length of 2-7 digits.

If (! Registration Test (str)){) (

Alert ("Sorry, the format of the string type you entered is incorrect!" ); //Please change "String Type" to the name of the property to be verified!

Returns false

}

}