-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path密码强度.html
138 lines (117 loc) · 3.05 KB
/
密码强度.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<li style="height:15px; line-height:15px;">
<dd style="height:15px;"> </dd>
<dt style="height:15px;">
<div class="ywz_zhuce_hongxianwenzi"> 弱</div>
<div class="ywz_zhuce_hongxianwenzi"> 中</div>
<div class="ywz_zhuce_hongxianwenzi"> 强</div>
</dt>
</li>
<script type="text/javascript">
$('#txtPwd').focus(function () {
$('#pwdLevel_1').attr('class', 'ywz_zhuce_hongxian');
$('#txtPwd').keyup();
});
$('#txtPwd').keyup(function () {
var __th = $(this);
if (!__th.val()) {
$('#pwd_tip').hide();
$('#pwd_err').show();
Primary();
return;
}
if (__th.val().length < 6) {
$('#pwd_tip').hide();
$('#pwd_err').show();
Weak();
return;
}
var _r = checkPassword(__th);
if (_r < 1) {
$('#pwd_tip').hide();
$('#pwd_err').show();
Primary();
return;
}
if (_r > 0 && _r < 2) {
Weak();
} else if (_r >= 2 && _r < 4) {
Medium();
} else if (_r >= 4) {
Tough();
}
$('#pwd_tip').hide();
$('#pwd_err').hide();
});
function Primary() {
$('#pwdLevel_1').attr('class', 'ywz_zhuce_huixian');
$('#pwdLevel_2').attr('class', 'ywz_zhuce_huixian');
$('#pwdLevel_3').attr('class', 'ywz_zhuce_huixian');
}
function Weak() {
$('#pwdLevel_1').attr('class', 'ywz_zhuce_hongxian');
$('#pwdLevel_2').attr('class', 'ywz_zhuce_huixian');
$('#pwdLevel_3').attr('class', 'ywz_zhuce_huixian');
}
function Medium() {
$('#pwdLevel_1').attr('class', 'ywz_zhuce_hongxian');
$('#pwdLevel_2').attr('class', 'ywz_zhuce_hongxian2');
$('#pwdLevel_3').attr('class', 'ywz_zhuce_huixian');
}
function Tough() {
$('#pwdLevel_1').attr('class', 'ywz_zhuce_hongxian');
$('#pwdLevel_2').attr('class', 'ywz_zhuce_hongxian2');
$('#pwdLevel_3').attr('class', 'ywz_zhuce_hongxian3');
}
function checkPassword(pwdinput) {
var maths, smalls, bigs, corps, cat, num;
var str = $(pwdinput).val()
var len = str.length;
var cat = /.{16}/g
if (len == 0) return 1;
if (len > 16) { $(pwdinput).val(str.match(cat)[0]); }
cat = /.*[\u4e00-\u9fa5]+.*$/
if (cat.test(str)) {
return -1;
}
cat = /\d/;
var maths = cat.test(str);
cat = /[a-z]/;
var smalls = cat.test(str);
cat = /[A-Z]/;
var bigs = cat.test(str);
var corps = corpses(pwdinput);
var num = maths + smalls + bigs + corps;
if (len < 6) { return 1; }
if (len >= 6 && len <= 8) {
if (num == 1) return 1;
if (num == 2 || num == 3) return 2;
if (num == 4) return 3;
}
if (len > 8 && len <= 11) {
if (num == 1) return 2;
if (num == 2) return 3;
if (num == 3) return 4;
if (num == 4) return 5;
}
if (len > 11) {
if (num == 1) return 3;
if (num == 2) return 4;
if (num > 2) return 5;
}
}
function corpses(pwdinput) {
var cat = /./g
var str = $(pwdinput).val();
var sz = str.match(cat)
for (var i = 0; i < sz.length; i++) {
cat = /\d/;
maths_01 = cat.test(sz[i]);
cat = /[a-z]/;
smalls_01 = cat.test(sz[i]);
cat = /[A-Z]/;
bigs_01 = cat.test(sz[i]);
if (!maths_01 && !smalls_01 && !bigs_01) { return true; }
}
return false;
}
</script>