-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.js
40 lines (37 loc) · 1009 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
35
36
37
38
39
40
userData = JSON.parse(localStorage.getItem("UserData")) || [];
var form = document.querySelector("form");
form.addEventListener("submit", myFunction);
function myFunction(event) {
event.preventDefault();
var name = form.name.value;
var email = form.email.value;
var password = form.password.value;
var contact = form.contact.value;
userObj = {
name: name,
email: email,
contact: contact,
password: password,
};
if (checkExist(userObj.email)) {
userData.push(userObj);
console.log(userData)
localStorage.setItem("UserData", JSON.stringify(userData));
alert("You are redirecting to Login page")
setTimeout(function () {
window.location.replace("signin.html")
}, 2000);
} else {
alert("Account Already Exists");
}
} //Close bracket of function
function checkExist(Email) {
var Filtered = userData.filter(function (el) {
return Email === el.email;
});
if (Filtered.length > 0) {
return false;
} else {
return true;
}
}