-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
32 lines (30 loc) · 1.06 KB
/
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
document.querySelector("#button").addEventListener("click", getData);
let userData = JSON.parse(localStorage.getItem("signupData")) || [];
function getData(event) {
let signupObj = {
userFname: document.querySelector("#firstName").value,
userLname: document.querySelector("#lastName").value,
userEmail: document.querySelector("#email").value,
userPassword: document.querySelector("#password").value,
};
validateDuplicate(signupObj);
}
let blanck = { userEmail: "", userPassword: "" };
function validateDuplicate(elem) {
let Data = userData.filter(function (element) {
return elem.userEmail !== element.userEmail;
});
if (
blanck.userEmail == elem.userEmail &&
blanck.userPassword == elem.userPassword
) {
alert("Please fill required field for signup.");
} else if (Data.length !== userData.length) {
alert("This email id already exist");
} else {
userData.push(elem);
localStorage.setItem("signupData", JSON.stringify(userData));
window.location.href = "login.html";
alert("You are successfully signup.");
}
}