4 Reg Expr
用户名(UN)://所有包含4-16个以上的字母、数字或下划线的字符串
var
uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
console.log(uPattern.test(
"iFat3"
));
密码(PW)://最少6位,包括至少1个大写字母,1个小写字母,1个数字,1个特殊字符
var
pPattern = /^.*(?=.{6,})(?=.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@
#$%^&*? ]).*$/;
console.log(
"=="
+pPattern.test(
"iFat3#"
));
邮箱(EM):
var
ePattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
console.log(ePattern.test(<a href=
"mailto:xxxxxxxxxxx@xxx.com"
>xxxxxx@xxx.com</a>));
身份证(ID Card):
v
ar
cP = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
console.log(cP.test(
"xxxxxxxxxxxxxxxxxx"
));//18位