-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword.strength.html
100 lines (100 loc) · 2.81 KB
/
password.strength.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
.container {
height: 100vh;
width: 100%;
background: #201f21;
display: flex;
align-items: center;
justify-content: center;
}
.input-box {
width: 400px;
position: relative;
max-width: 90%;
}
.input-box input {
width: 100%;
height: 60px;
padding: 0 20px;
border: 1px solid #ccc;
outline: none;
color: #fff;
background: transparent;
}
button {
background: transparent;
border: none;
outline: 0;
border-radius: 50%;
cursor: pointer;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 15px;
}
button img {
width: 35px;
}
#message {
position: absolute;
bottom: -30px;
color: #fff;
font-size: 15px;
}
::placeholder {
font-size: 15px;
}
</style>
</head>
<body>
<main class="container">
<div class="input-box">
<input type="password" id="password" placeholder="password">
<button type="submit">
<img src="images/arrow.png" alt="">
</button>
<p id="message">Password is <span id="strength"></span></p>
</div>
</main>
<script>
var pass = document.getElementById('password');
var msg = document.getElementById('message');
var str = document.getElementById('strength');
pass.addEventListener('input', ()=>{
if(pass.value.length > 0){
msg.style.display = 'block';
}
else {
msg.style.display = 'none'
}
if(pass.value.length < 4){
str.innerHTML = 'weak';
pass.style.borderColor = '#ff5925';
msg.style.color = '#ff5925';
}
else if(pass.value.length >= 4 && pass.value.length < 8){
str.innerHTML = 'medium';
pass.style.borderColor = 'yellow';
msg.style.color = 'yellow';
}
else if(pass.value.length >= 8){
str.innerHTML = 'strong';
pass.style.borderColor = '#26d730';
msg.style.color = '#26d730';
}
})
</script>
</body>
</html>