-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword.html
More file actions
72 lines (67 loc) · 1.81 KB
/
Copy pathpassword.html
File metadata and controls
72 lines (67 loc) · 1.81 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Strength Checker</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
input[type="password"] {
width: 300px;
padding: 8px;
font-size: 16px;
}
#strength {
margin-top: 10px;
font-weight: bold;
font-size: 18px;
}
.weak {
color: red;
}
.medium {
color: orange;
}
.strong {
color: green;
}
</style>
</head>
<body>
<h2>Password Strength Checker</h2>
<input type="password" id="a" placeholder="Enter your password">
<div id="strength">Strength: <span id="b">—</span></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
$(document).ready(function() {
$("#a").keyup(function() {
let length = $(this).val().length;
let strengthText = "";
let colorClass = "";
if (length < 4 && length > 0) {
strengthText = "Weak";
colorClass = "weak";
}
else if (length >= 4 && length <= 8) {
strengthText = "Medium";
colorClass = "medium";
}
else if (length > 8) {
strengthText = "Strong";
colorClass = "strong";
}
else {
strengthText = "—";
}
$("#b")
.text(strengthText)
.removeClass("weak medium strong")
.addClass(colorClass);
});
});
</script>
</body>
</html>