-
Notifications
You must be signed in to change notification settings - Fork 2
/
login.html
101 lines (95 loc) · 3.92 KB
/
login.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
<!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>SignIn</title>
<link rel="stylesheet" href="login.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
</head>
<body>
<div class="form login">
<div class="form-content">
<header>Sign In</header>
<form id="signIn" action="#">
<div class="field input-field">
<input id="mailIn" type="email" placeholder="Email" class="input">
</div>
<div class="field input-field">
<input id="passIn" type="password" placeholder="Password" class="password">
<i id="eyeOpen" class="fa-sharp fa-solid fa-eye "></i>
<i id='eyeClosed'class="fa-solid fa-eye-slash"></i>
</div>
<div class="form-link">
<a href="#" class="forgot-pass">Forgot Password?</a>
</div>
<div class="field button-field">
<!-- <button>Login</button> -->
<input id="login" type="submit" value="Login" />
</div>
<div class="form-link">
<span>Already have an Account?<a href="signup.html" class="signup-link">SignUp</a></span>
</div>
</form>
</div>
</div>
</body>
<script>
let customers=JSON.parse(localStorage.getItem("customers"));
if(customers==null){
customers=[];
}
let signInForm=document.getElementById("signIn");
signInForm.addEventListener("submit",(e)=>{
e.preventDefault();
console.log(customers);
let flag=false;
for(let customer of customers){
if(signInForm.mailIn.value==customer.email && signInForm.passIn.value==customer.pass ){
// alert(`Very welcome ${customer.name}`);
swal({
title:`Very welcome ${customer.name}, you have logged in with ${customer.email}` ,
text: "Sign in successfull!",
icon:`${customer.email}`,
button: "go ahead!",
}).then(()=>{
// event.preventDefault();
// window.location = "menu.html";
});
// return
flag=true;
let name=customer.name;
let email=customer.email;
// let phone=customer.phone;
let pass=customer.pass;
let obj={name,email,pass};
console.log(obj)
localStorage.setItem("loggedCustomer",JSON.stringify(obj))
return;
}
}
if(!flag){
alert("enter the correct credential please")
}
});
let eyeClosed=document.getElementById("eyeClosed");
let eyeOpen=document.getElementById("eyeOpen");
eyeClosed.addEventListener("click",()=>{
let passText=document.querySelector("#passIn");
eyeOpen.style.display = "block";
eyeClosed.style.display = "none";
// eyeOpen.classList.add('show');
passText.type='text';
})
eyeOpen.addEventListener("click",()=>{
let passText=document.querySelector("#passIn");
eyeOpen.style.display = "none";
eyeClosed.style.display = "block";
passText.type='password';
})
</script>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js" integrity="sha512-AA1Bzp5Q0K1KanKKmvN/4d3IRKVlv9PYgwFPvm32nPO6QS8yH1HO7LbgB1pgiOxPtfeg5zEn2ba64MUcqJx6CA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- <i id="eyeClosed" class="fa-sharp fa-solid fa-eye"></i>
<i id='eyeOpen'class="fa-solid fa-eye-slash"></i> -->