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