Skip to content

Commit 51138ab

Browse files
committed
Created Password Strength Meter
1 parent 015989d commit 51138ab

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

Password-Strength-Meter/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>CSS Only Password Strength Meter</title>
7+
<style>
8+
* {
9+
box-sizing: border-box;
10+
}
11+
12+
input:invalid ~ .strength::before {
13+
width: 30%;
14+
background: #ff4d4d;
15+
}
16+
17+
input:valid ~ .strength::before {
18+
width: 100%;
19+
background: #4caf50;
20+
}
21+
22+
input:not(:placeholder-shown):not(:valid):not(:invalid) ~ .strength::before {
23+
width: 60%;
24+
background: #fbc02d;
25+
}
26+
27+
.hint {
28+
font-size: 13px;
29+
color: #666;
30+
margin-top: 10px;
31+
text-align: left;
32+
}
33+
34+
input:valid {
35+
border-color: #4caf50;
36+
box-shadow: 0 0 8px rgba(76,175,80,0.3);
37+
}
38+
39+
input:invalid {
40+
border-color: #ff4d4d;
41+
}
42+
</style>
43+
</head>
44+
<body>
45+
46+
<div class="container">
47+
<h2>Create Password</h2>
48+
<form>
49+
<input type="password" placeholder="Enter password"
50+
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*]).{8,}" required>
51+
<div class="strength"></div>
52+
<div class="hint">
53+
Must contain at least 8 characters, including<br>
54+
1 uppercase, 1 lowercase, 1 number, and 1 symbol.
55+
</div>
56+
</form>
57+
</div>
58+
59+
</body>
60+
</html>

0 commit comments

Comments
 (0)