-
Notifications
You must be signed in to change notification settings - Fork 1
/
signin.js
36 lines (25 loc) · 836 Bytes
/
signin.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
36
let signinBtn=document.getElementById("signin")
let userData=JSON.parse(localStorage.getItem("userData")) || []
let NameArr = [];
signinBtn.addEventListener("click",()=>{
let logEmail=document.getElementById("email").value
let logPass=document.getElementById("pass").value
let isVaild=false
let alName=""
for(let i=0;i<userData.length;i++){
alName =userData[i].firstName
if(userData[i].email==logEmail){
if(userData[i].password==logPass){
isVaild=true
}
}
}
if(isVaild){
alert(`${alName} You Are Logged In Now`)
NameArr.push(alName)
localStorage.setItem("Name" , JSON.stringify(NameArr))
window.location.href = "./index.html"
}else{
alert(`Sorry Check Your Details Again`)
}
})