验证数字,大写字母,小写字母,特殊字符四选三组成的密码强度,且长度在8到30个数之间
表达式:
^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-ZW_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-zW_!@#$%^&*`~()-+=]+$)(?![0-9W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9W_!@#$%^&*`~()-+=]{8,30}$
js写法:
var regex = new RegExp('^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-ZW_!@#$%^&*`~()-+=]+$)(?![a-z0-9]+$)(?![a-zW_!@#$%^&*`~()-+=]+$)(?![0-9W_!@#$%^&*`~()-+=]+$)[a-zA-Z0-9W_!@#$%^&*`~()-+=]{8,30}$'); if(!regex.test(pwd)){ msgError("输入错误:密码不符合规则,请重新输入。"); $("#password").focus(); return; }
js正则表达式密码验证必须包含数字和字母
多条正则验证思路就是分开验证是否包含数字、字母、长度等限制条件
/^(?=.*?[a-z)(?=.*>[A-Z])(?=.*?[0-9])[a-zA_Z0-9]{6,10}$/