/**
* @desc get_pwd_strength()im:根据密码字符串判断密码结构
* @param (string)$mobile
* return 返回:$msg
*/
function get_pwd_strength($pwd){
if (strlen($pwd)>30 || strlen($pwd)<6) {="" return="" "密码必须为6-30位的字符串";="" }="" if(preg_match("="" ^d*$="" ",$pwd))="" "密码必须包含字母,强度:弱";="" 全数字="" ^[a-z]*$="" i",$pwd))="" "密码必须包含数字,强度:中";="" 全字母="" if(!preg_match("="" ^[a-zd]*$="" "密码只能包含数字和字母,强度:强";="" 有数字有字母="" ";="" }
js 正则匹配/**
* 检测密码强度,必须由数字与字母组合,至少6位的字符串。
*/
$.checkPwd = function(v){
v=$.trim(v);
if(v.length30){
return "密码长度为6-30位";
}
if(/^d+$/.test(v))
{
return "全数字";
}
if(/^[a-z]+$/i.test(v))
{
return "全字母";
}
if(!/^[A-Za-z0-9]+$/.test(v))
{
return "只能含有数字有字母";
}
return "正确";
};
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读: