-
Notifications
You must be signed in to change notification settings - Fork 581
/
newLogin.html
239 lines (217 loc) · 9.42 KB
/
newLogin.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!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>Tourguide</title>
<link rel="icon" type="image/x-icon" href="log/favicon.ico">
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
<script src="https://kit.fontawesome.com/f2e55912f8.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./login/login.css">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
</head>
<body>
<div id="loginSuccessBanner" class="success-banner">Logged in successfully</div>
<div id="loginDeclineBanner" class="decline-banner">Logged in Blocked <br> credentials didn't match</div>
<div id="registerSuccessBanner" class="success-banner">Registered successfully</div>
<div id="registerDeclineBanner" class="decline-banner">Registered Blocked <br> Same email address</div>
<div>
<a href="index.html">
<button style="padding: 25px 25px 25px 25px; border-radius: 40px; font-size: 20px;">
<i class="lni lni-home"></i>
</button>
</a>
</div>
<div class="main-container">
<div class="container" id="container">
<div class="form-container register-container">
<form id="registerForm">
<h1>Tour Guide</h1>
<input type="text" placeholder="Name" id="registerName">
<input type="email" placeholder="Email" id="registerEmail">
<div id="register-section" class="input-container">
<input type="password" placeholder="Password" id="registerPassword" oninput="checkPasswordStrength()">
<button type="button" id="toggleRegisterPassword">
<i id="registerIcon" class="fas fa-eye"></i>
</button>
</div>
<small id="passwordStrengthMsg" style="color: red;"></small>
<button type="submit">Register</button>
<div class="social-container">
<a class="fb" href="www.facebook.com" class="social"><i class="lni lni-facebook-fill"></i></a>
<a class="goog" href="www.google.com" class="social"><i class="lni lni-google"></i></a>
<a class="lin" href="www.linkedin.com" class="social"><i class="lni lni-linkedin-original"></i></a>
</div>
</form>
</div>
<div class="form-container login-container">
<form id="loginForm">
<h1>Tour Guide</h1>
<input type="email" placeholder="Email" id="loginEmail">
<div id="login-section" class="input-container">
<input type="password" placeholder="Password" id="loginPassword">
<button type="button" id="toggleLoginPassword">
<i id="loginIcon" class="fas fa-eye"></i>
</button>
</div>
<div class="content">
<div class="checkbox">
<input type="checkbox" name="checkbox" id="checkbox">
<label>Remember me</label>
</div>
<div class="pass-link">
<a href="#">Forgot password?</a>
</div>
</div>
<button type="submit">Login</button>
<span>or use your account</span>
<div class="social-container">
<a class="fb" href="www.facebook.com" class="social"><i class="lni lni-facebook-fill"></i></a>
<a class="goog" href="www.google.com" class="social"><i class="lni lni-google"></i></a>
<a class="lin" href="www.linkedin.com" class="social"><i class="lni lni-linkedin-original"></i></a>
</div>
</form>
</div>
<div class="overlay-container">
<div class="overlay">
<div class="overlay-panel overlay-left">
<h1 class="title">Hello <br> friends</h1>
<p>If you have an account, login here and have fun</p>
<button class="ghost" id="login">Login
<i class="lni lni-arrow-left login"></i>
</button>
</div>
<div class="overlay-panel overlay-right">
<h1 class="title">Start your <br> journey now</h1>
<p>If you don't have an account yet, join us and start your journey.</p>
<button class="ghost" id="register">Register
<i class="lni lni-arrow-right register"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<script src="login/script.js"></script>
<script>
function checkPasswordStrength() {
const password = document.getElementById("registerPassword").value;
const strengthMsg = document.getElementById("passwordStrengthMsg");
let strength = "Weak";
let color = "red";
if (password.length >= 8 && /[A-Z]/.test(password) && /[a-z]/.test(password) && /[0-9]/.test(password) && /[!@#\$%\^\&*\)\(+=._-]/.test(password)) {
strength = "Strong";
color = "green";
} else if (password.length >= 6 && ((/[A-Z]/.test(password) && /[a-z]/.test(password)) || /[0-9]/.test(password))) {
strength = "Medium";
color = "orange";
}
strengthMsg.textContent = `Password strength: ${strength}`;
strengthMsg.style.color = color;
}
document.addEventListener("DOMContentLoaded", function () {
const registerButton = document.getElementById("register");
const loginButton = document.getElementById("login");
const container = document.getElementById("container");
registerButton.addEventListener("click", (event) => {
event.preventDefault();
container.classList.add("right-panel-active");
document.getElementById("registerForm").scrollIntoView({ behavior: "smooth" });
});
loginButton.addEventListener("click", (event) => {
event.preventDefault();
container.classList.remove("right-panel-active");
document.getElementById("loginForm").scrollIntoView({ behavior: "smooth" });
});
// Form validation and submission
document.getElementById("registerForm").addEventListener("submit", function (event) {
event.preventDefault();
validateForm("register");
});
//Form validation for registration name
document.getElementById("registerName").addEventListener("keypress", function (event) {
var char = String.fromCharCode(event.which);
if (!(/[a-zA-Z]/.test(char))) {
event.preventDefault();
}
});
document.getElementById("loginForm").addEventListener("submit", function (event) {
event.preventDefault();
validateForm("login");
});
function validateForm(formType) {
let email, password, name;
const spcharRegex = /[<>"/]/;
if (formType === "register") {
name = document.getElementById("registerName").value;
email = document.getElementById("registerEmail").value;
password = document.getElementById("registerPassword").value;
if (name === "" || email === "" || password === "") {
alert("Please fill in all fields");
return;
}
if (!validateEmail(email)) {
alert("Please enter a valid email address");
return;
}
if (spcharRegex.test(name) || spcharRegex.test(password)) {
alert('Name Or Password Cannot Contain <,>,", or /');
return;
}
if (localStorage.getItem("email") === email) {
registerDeclineBanner.style.display = "block";
setTimeout(() => {
registerDeclineBanner.style.display = "none";
}, 6000);
}
localStorage.setItem("name", name);
localStorage.setItem("email", email);
localStorage.setItem("password", password);
registerSuccessBanner.style.display = "block";
setTimeout(() => {
registerSuccessBanner.style.display = "none";
document.getElementById("registerName").value = "";
document.getElementById("registerEmail").value = "";
document.getElementById("registerPassword").value = "";
}, 3000);
} else {
email = document.getElementById("loginEmail").value;
password = document.getElementById("loginPassword").value;
if (email === "" || password === "") {
alert("Please fill in all fields");
return;
}
if (!validateEmail(email)) {
alert("Please enter a valid email address");
return;
}
if (spcharRegex.test(password)) {
alert('Password Cannot Contain <,>,", or /');
return;
}
const storedEmail = localStorage.getItem("email");
const storedPassword = localStorage.getItem("password");
if (email === storedEmail && password === storedPassword) {
loginSuccessBanner.style.display = "block";
setTimeout(() => {
loginSuccessBanner.style.display = "none";
document.getElementById("loginEmail").value = "";
document.getElementById("loginPassword").value = "";
}, 3000);
} else {
loginDeclineBanner.style.display = "block";
setTimeout(() => {
loginDeclineBanner.style.display = "none";
}, 6000);
}
}
}
function validateEmail(email) {
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
return re.test(email);
}
});
</script>
</body>
</html>