-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path119. ValidatePassword.html
119 lines (98 loc) · 2.94 KB
/
119. ValidatePassword.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ValidatePassword</title>
<style>
body {
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 3px solid black;
height: 50vh;
width: 20vw;
border-radius: 7px;
}
.form-main {
display: flex;
flex-direction: column;
align-items: center;
width: 80%;
}
.form-main label {
font-size: 24px;
font-weight: 500;
}
.form-main input {
width: 80%;
height: 25px;
border: 2px solid blue;
margin: 20px;
}
.form-main button {
padding: 7px 30px;
border: 1px solid red;
background-color: pink;
font-size: 16px;
font-weight: 600;
}
.form-footer {
height: 20%;
}
.form-footer p {
font-size: 18px;
font-weight: 600;
}
</style>
</head>
<body>
<div class="form">
<div class="form-main">
<label for="email">Enter your email:</label>
<input type="text" name="email" id="email">
<label for="password">Enter your password:</label>
<input type="text" name="password" id="password">
<button type="submit" onclick="check()">Submit</button>
</div>
<div class="form-footer">
<p id="response"></p>
</div>
</div>
<script>
let check = () => {
let email = document.querySelector("#email").value;
console.log(email);
let password = document.querySelector("#password").value;
console.log(password);
let flag = 0;
for (let i = 0; i < email.length; i++) {
if (email[i] == "@") {
flag++;
}
}
console.log(flag);
if ((flag == 0) || (password.length <= 8)) {
let response = document.querySelector("#response");
response.innerHTML = "Invalid email or password!";
response.style.color = "red";
}
else {
let response = document.querySelector("#response");
response.innerHTML = "Valid email and password!";
response.style.color = "green";
}
}
</script>
</body>
</html>