-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.js
54 lines (37 loc) · 1.34 KB
/
login.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
37
38
39
40
41
42
43
44
45
46
47
48
49
var arr_name_and_passwords=[
{email: "Harry@gmail.com", password: "HarryPotter456"},
{email: "Albus@gmail.com", password: "Magic456"},
{email: "Snape@gmail.com", password: "Lilly789"},
{email: "Tom@gmail.com", password: "DarkLord456"}
]
var len= arr_name_and_passwords.length
window.onload= function(){
var get_btn= document.getElementById("submit_btn")
get_btn.addEventListener("click", get_values)
localStorage.setItem("names",JSON.stringify(arr_name_and_passwords))
}
function get_values()
{
event.preventDefault()
var email= document.getElementById("user_email").value
var password= document.getElementById("user_password").value
verify_values(email, password)
}
function verify_values(email, password)
{
var get_wrong_login= document.getElementById("wrong_login")
for(var i=0; i<len; i++)
{
if(email==arr_name_and_passwords[i].email && password==arr_name_and_passwords[i].password)
{
//console.log("MATCH")
window.location.href= "dash.html"
alert("Login Successful")
break
}
else
{
get_wrong_login.innerHTML="Wrong email or password"
}
}
}