-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup1.html
122 lines (102 loc) · 2.87 KB
/
signup1.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
<!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>Signup</title>
<style>
*{
margin: 0px;
padding: 0px;
}
body{
background-color:#252525;
}
form{
width: 40%;
background-color:#252525;
margin: 10% auto;
padding: 5%;
}
input,button{
width: 50%;
display: block;
margin-top: 10px;
margin: auto;
padding: 10px;
}
#signup{
width: 55%;
margin-top: 20px;
background-color: red;
color: white;
border: none;
}
h1{
text-align: center;
color: white;
font-size: 40px;
margin-top: 10px;
}
p{
text-align: center;
color: white;
margin-top: 30px;
font-size: 20px;
}
#login{
color:gray;
}
input{
margin-bottom: 10px;
border-radius: 7px;
}
</style>
</head>
<body>
<h1>Register</h2>
<p>Please fill in the fields below:</p>
<div>
<form>
<input id="firstname" placeholder="First Name" type="text" >
<input type="text" id="lastname" placeholder="Last Name">
<input type="email" id="email" placeholder="Email">
<input type="password" id="password" placeholder="Password">
<button id="signup">CREATE ACCOUNT</button>
<p id="login">Already Have An Account? <a href="login.html">Login</a></p>
</form>
</div>
</body>
</html>
<script>
let form=document.querySelector("form");
let userData= JSON.parse(localStorage.getItem("userData"))|| [] ;
form.addEventListener("submit",function(event){
event.preventDefault() ;
let data={
fname:form.firstname.value,
lname:form.lastname.value,
email:form.email.value,
password:form.password.value
}
if(checkEmail(data.email)===true){
userData.push(data)
localStorage.setItem("userData",JSON.stringify(userData));
window.location.href="login.html"
}else{
alert("Account Already Exists")
window.location.href="login.html"
}
})
function checkEmail(email){
let filtered=userData.filter(function(elm){
return email===elm.email;
})
if(filtered.length>0){
return false
}else{
return true
}
}
</script>