一、php页面
$score = 0;
if(!empty($_get['value'])){ //接收的值
$str = $_get['value'];
}else{
$str = '';
}
if(preg_match(/[0-9]+/,$str))
{
$score ++;
}
if(preg_match(/[0-9]{3,}/,$str))
{
$score ++;
}
if(preg_match(/[a-z]+/,$str))
{
$score ++;
}
if(preg_match(/[a-z]{3,}/,$str))
{
$score ++;
}
if(preg_match(/[a-z]+/,$str))
{
$score ++;
}
if(preg_match(/[a-z]{3,}/,$str))
{
$score ++;
}
if(preg_match(/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]+/,$str))
{
$score += 2;
}
if(preg_match(/[_|\-|+|=|*|!|@|#|$|%|^|&|(|)]{3,}/,$str))
{
$score ++ ;
}
if(strlen($str) >= 10)
{
$score ++;
}
echo $score;exit;
二、html页面
输入密码:
密码强度:
弱
无中等
强
极好
三、js
function getpassword(){
var value = $(input[name='newpwd']).attr('value');
$.get('index.php?r=account/testpwd',{value:value},function(data){
if(data>=1 && data$('#idsm1').attr('class','pwdchkcon1'); //弱
$('#idsm2').attr('class','pwdchkcon0');
$('#idsm3').attr('class','pwdchkcon0');
$('#idsm4').attr('class','pwdchkcon0');
$('#idsmt1').show();
$('#idsmt0').hide();
$('#idsmt2').hide();
$('#idsmt3').hide();
$('#idsmt4').hide();
}else if(data>=4 && data$('#idsm1').attr('class','pwdchkcon2');
$('#idsm2').attr('class','pwdchkcon2');
$('#idsm3').attr('class','pwdchkcon0');
$('#idsm4').attr('class','pwdchkcon0');
$('#idsmt0').hide();
$('#idsmt1').hide();
$('#idsmt2').show();
$('#idsmt3').hide();
$('#idsmt4').hide();
}else if(data>=7 && data$('#idsm1').attr('class','pwdchkcon3');
$('#idsm2').attr('class','pwdchkcon3');
$('#idsm3').attr('class','pwdchkcon3');
$('#idsm4').attr('class','pwdchkcon0');
$('#idsmt0').hide();
$('#idsmt1').hide();
$('#idsmt2').hide();
$('#idsmt3').show();
$('#idsmt4').hide();
}else if(data>=9 && data$('#idsm1').attr('class','pwdchkcon4');
$('#idsm2').attr('class','pwdchkcon4');
$('#idsm3').attr('class','pwdchkcon4');
$('#idsm4').attr('class','pwdchkcon4');
$('#idsmt0').hide();
$('#idsmt1').hide();
$('#idsmt2').hide();
$('#idsmt3').hide();
$('#idsmt4').show();
}
});
}
四、css
.pwdchkcon0 {border-right: #bebebe 1px solid;border-bottom: #bebebe 1px solid;background-color: #ebebeb;text-align: center;}
.pwdchkcon1 {border-right: #bb2b2b 1px solid;border-bottom: #bb2b2b 1px solid;background-color: #ff4545;text-align: center;}
.pwdchkcon2 {border-right: #e9ae10 1px solid;border-bottom: #e9ae10 1px solid;background-color: #ffd35e;text-align: center;}
.pwdchkcon3 {border-right: #267a12 1px solid;border-bottom: #267a12 1px solid;background-color: #3abb1c;text-align: center;}
.pwdchkcon4 {border-right: #267a12 1px solid;border-bottom: #267a12 1px solid;background-color: #3abb1c;text-align: center;}
http://www.bkjia.com/phpjc/532684.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/532684.htmltecharticle一、php页面 $score = 0; if(!empty($_get[value])){ //接收的值 $str = $_get[value]; }else{ $str = ; } if(preg_match(/[0-9]+/,$str)) { $score ++; } if(preg_match(/[0-9]{3,}/,$s...