-
Notifications
You must be signed in to change notification settings - Fork 11
/
script1.js
35 lines (32 loc) · 1.59 KB
/
script1.js
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
const isLoggedIn = sessionStorage.getItem("isLoggedIn");
if (!isLoggedIn && window.location.pathname !== "/login1.html" && window.location.pathname !== "/signup1.html") {
window.location.href = "login1.html";
}
document.getElementById("loginForm").addEventListener("submit", function (event) {
event.preventDefault();
const username = document.getElementById("username").value;
const password = document.getElementById("password").value;
// Replace this with actual login validation logic.
// For the sake of simplicity, we are allowing any non-empty username/password combination.
if (username.trim() && password.trim()) {
sessionStorage.setItem("isLoggedIn", "true");
window.location.href = "index.html";
} else {
alert("Invalid login credentials. Please try again.");
}
});
document.getElementById("signupForm").addEventListener("submit", function (event) {
event.preventDefault();
const username = document.getElementById("username").value;
const email = document.getElementById("email").value;
const phone = document.getElementById("phone").value;
const password = document.getElementById("password").value;
// Replace this with actual signup logic.
// For the sake of simplicity, we are allowing any non-empty username/email/password combination.
if (username.trim() && email.trim() && phone.trim() && password.trim()) {
sessionStorage.setItem("isLoggedIn", "true");
window.location.href = "index.html";
} else {
alert("Invalid signup information. Please fill all fields and try again.");
}
});