//姓名
var ren = /((^[\u4E00-\u9FA5]{2,5}$)|(^[a-zA-Z]+[\s\.]?([a-zA-Z]+[\s\.]?){0,4}[a-zA-Z]$))/;
if(name==""){
showTip("nameMsg","请输入您的姓名");
return;
}else if(name.length<2){
showTip("nameMsg","姓名至少包含两个字");
return;
}else if (!ren.test(name)) {
showTip("nameMsg","姓名只能是纯汉字");
return;
}else if (name.length>=5){
showTip("nameMsg","您的姓名过长");
return;
}
var reg2 = /^[\u4E00-\u9FA5]{2,4}$/;//Unicode编码中的汉字范围
if(!reg2.test(name)){
showTip("nameMsg","请输入中文");
return;
}
转载于:https://my.oschina.net/hehongbo/blog/703894