-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
25 lines (25 loc) · 720 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
document.querySelector("#form").addEventListener("submit", collectData);
arr = JSON.parse(localStorage.getItem("signupdata")) || [];
function collectData(event) {
event.preventDefault();
data = {
pname: form.name.value,
email: form.mail.value,
pass: form.password.value,
pass1: form.password1.value,
};
if (data.email == "" || data.number == "" || data.pass == "") {
alert("Fill all the details");
} else if (data.pass != data.pass1) {
alert("Passwords must match");
} else {
console.log("hello");
arr.push(data);
store(arr);
form.reset();
}
}
function store(arr) {
localStorage.setItem("signupdata", JSON.stringify(arr));
window.location.href = "Login.html";
}