-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
49 lines (47 loc) · 1.58 KB
/
Copy pathfunctions.js
File metadata and controls
49 lines (47 loc) · 1.58 KB
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
function passwordStrength(e) {
return score = 0,
score += 4 * e.length,
score += 1 * (checkRepetition(1, e).length - e.length),
score += 1 * (checkRepetition(2, e).length - e.length),
score += 1 * (checkRepetition(3, e).length - e.length),
score += 1 * (checkRepetition(4, e).length - e.length),
e.match(/(.*[0-9].*[0-9].*[0-9])/) && (score += 5),
e.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/) && (score += 5),
e.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/) && (score += 10),
e.match(/([a-zA-Z])/) && e.match(/([0-9])/) && (score += 15),
e.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && e.match(/([0-9])/) && (score += 15),
e.match(/([!,@,#,$,%,^,&,*,?,_,~])/) && e.match(/([a-zA-Z])/) && (score += 15),
(e.match(/^\w+$/) || e.match(/^\d+$/)) && (score -= 10),
score
}
function nonZeroLength(e) {
var t = $(e).val();
return 0 != t.length
}
function onlyNumber(e) {
var t = $(e).val()
, i = /^[0-9, ' ']*$/;
return i.test(t)
}
function alphaNum(e) {
var t = $(e).val()
, i = /[.*+=_~&?!^@#%;,\/\\${}()|[\]]/;
return !i.test(t)
}
function onlyAlpha(e) {
var t = $(e).val()
, i = /[0-9.*+=_~&?!^@#%;,\/\\${}()|[\]]/;
return !i.test(t)
}
function checkRepetition(e, t) {
for (res = "",
i = 0; i < t.length; i++) {
for (repeated = !0,
j = 0; j < e && j + i + e < t.length; j++)
repeated = repeated && t.charAt(j + i) == t.charAt(j + i + e);
j < e && (repeated = !1),
repeated ? (i += e - 1,
repeated = !1) : res += t.charAt(i)
}
return res
}