-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.js
More file actions
43 lines (39 loc) · 1.24 KB
/
signup.js
File metadata and controls
43 lines (39 loc) · 1.24 KB
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
// script for sign up page
let form = document.querySelector("form")
form.addEventListener("submit",Getdata);
let signupdata = JSON.parse(localStorage.getItem("SignupDATA")) || [];
// function to get data from user and set it in the local storage.
function Getdata(){
event.preventDefault();
if(form.password.value.length >= 10){
let signupdataobj = {
email : form.email.value,
name : form.firstname.value +" "+form
.lastname.value,
pasw : form.password.value,
DOB : form.date.value+"-"+form.month.value+"-"+form.year.value,
}
if(checkdata(signupdataobj) == true){
signupdata.push(signupdataobj)
localStorage.setItem("SignupDATA",JSON.stringify(signupdata));
window.location.reload();
window.location.href="login.html"
}else{
alert("Seems like you already have an account");
}
}
else{
alert("Your Password must be 10 characters long")
}
}
// function to check wether the user already has an account or not.
function checkdata(signupdataobj){
let filter = signupdata.filter(function(el){
return el.email == signupdataobj.email;
})
if(filter.length > 0){
return false;
}else{
return true;
}
}