forked from taruntailor7/fraazo-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
34 lines (29 loc) · 859 Bytes
/
signup.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
var user = JSON.parse(localStorage.getItem("user")) || [];
document.querySelector("form").addEventListener("submit", getData);
function getData() {
event.preventDefault();
var data = {
name: document.getElementById("name").value,
mobile : document.getElementById("mobile").value,
email: document.getElementById("email").value,
password: document.getElementById("pass").value,
};
var flag = false;
for(var i=0;i<user.length;i++) {
if(data.email === user[i].email){
flag = true;
break;
}
}
if(flag == true){
alert("User already exists !");
}
else{
user.push(data);
localStorage.setItem("user", JSON.stringify(user));
alert("Successfully Signed Up !");
window.location.href = "./login.html";
}
// alert("Successfully Signed Up !");
// window.location.href = "./login.html";
}