用Javascript实现评估用户输入密码的强度(2)
function pwstrength(pwd){
o_color="#eeeeee";
l_color="#ff0000";
m_color="#ff9900";
h_color="#33cc00";
if (pwd==null||pwd==''){
lcolor=mcolor=hcolor=o_color;
}
else{
s_level=checkstrong(pwd);
switch(s_level) {
case 0:
lcolor=mcolor=hcolor=o_color;
case 1:
lcolor=l_color;
mcolor=hcolor=o_color;
break;
case 2:
lcolor=mcolor=m_color;
hcolor=o_color;
break;
default:
lcolor=mcolor=hcolor=h_color;
}
}
document.getelementbyid("strength_l").style.background="/lcolor";
document.getelementbyid("strength_m").style.background=mcolor;
document.getelementbyid("strength_h").style.background=hcolor;
return;
}
</script>
<form name=form1 action="" >
输入密码:<input type=password size=10 onkeyup=pwstrength(this.value) onblur=pwstrength(this.value)>
<br>密码强度:
<table width="217" border="1" cellspacing="0" cellpadding="1" bordercolor="#cccccc" height="23" style='display:inline'>
<tr align="center" bgcolor="#eeeeee">
<td width="33%" id="strength_l">弱</td>
<td width="33%" id="strength_m">中</td>
<td width="33%" id="strength_h">强</td>
</tr>
</table>
</form>
Tag: 密码
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。