本文给大家分享一段简单的代码,实现根据密码长度显示安全条功能,代码如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
//根据密码长度显示安全条 <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实现根据密码长度显示安全条,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://blog.csdn.net/yanfangphp/article/details/22402901