//根据密码长度显示安全条 <ul class="clear"> <li>密码:</li> <li> <input type="password" id="pwd" name="pwd" class="in" onkeyup=pwstrength(this.value) onblur=pw_y("pwd","pwd1")></li> <li><em class="red">*</em></li> <li class="i2 grey"><table border="0" bordercolor="#cccccc" style='display:marker'> <tr align="center"> <td id="strength_l" bgcolor="#eeeeee">弱</td> <td id="strength_m" bgcolor="#eeeeee">中</td> <td id="strength_h" bgcolor="#eeeeee">强</td> <td align="left" > <label id="pwd1">使用数字,字母,下划线,长度在 6 - 20 个字符之间</label></td> </tr> </table> </li> </ul> 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; }
相关推荐:
正则匹配密码只能是数字和字母组合字符串功能
以上就是php根据密码长度显示安全条实例的详细内容。
