forked from apu52/Travel_Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
newLogin.html
217 lines (200 loc) · 8.95 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
<!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">
</head>
<body>
<div id="loginSuccessBanner" class="success-banner">Logged in successfully</div>
<div id="registerSuccessBanner" class="success-banner">Registered successfully</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">
<button type="button" id="toggleRegisterPassword">
<i id="registerIcon" class="fas fa-eye"></i>
</button>
</div>
<button type="submit">Register</button>
<!-- <span id="registerMessage" style="display: none;">Account created successfully</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="form-container login-container">
<form id="loginForm">
<h1><a style="margin-right: 300px;" href="index.html" class="back-to-home">
<!-- <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 24 24">
<path d="M19 12H5M5 12L12 19M5 12L12 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg> -->
</a>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>
<!-- Back to Home Button -->
</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>
document.addEventListener("DOMContentLoaded", function() {
const registerButton = document.getElementById("register");
const container = document.getElementById("container");
registerButton.addEventListener("click", (event) => {
event.preventDefault();
container.classList.add("right-panel-active");
document.getElementById("registerForm").scrollIntoView({ behavior: "smooth" });
});
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function () {
const registerButton = document.getElementById("register");
const loginButton = document.getElementById("login");
const container = document.getElementById("container");
const loginSuccessBanner = document.getElementById("loginSuccessBanner");
const registerSuccessBanner = document.getElementById("registerSuccessBanner");
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");
});
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;
}
// Show register success banner
registerSuccessBanner.style.display = "block";
setTimeout(() => {
registerSuccessBanner.style.display = "none";
}, 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;
}
// Show login success banner
loginSuccessBanner.style.display = "block";
setTimeout(() => {
loginSuccessBanner.style.display = "none";
}, 3000);
}
}
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
// Password toggle visibility for login
const togglePassword = document.getElementById("togglePassword");
const passwordInput = document.getElementById("loginPassword");
togglePassword.addEventListener("click", function () {
const type = passwordInput.getAttribute("type") === "password" ? "text" : "password";
passwordInput.setAttribute("type", type);
this.classList.toggle("fa-eye");
this.classList.toggle("fa-eye-slash");
});
// Password toggle visibility for register
const toggleRegisterPassword = document.getElementById("toggleRegisterPassword");
const passwordRegisterInput = document.getElementById("registerPassword");
toggleRegisterPassword.addEventListener("click", function () {
const type = passwordRegisterInput.getAttribute("type") === "password" ? "text" : "password";
passwordRegisterInput.setAttribute("type", type);
this.classList.toggle("fa-eye");
this.classList.toggle("fa-eye-slash");
});
});
</script>
</body>
</html>