forked from mukundjha1310/Envoy.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.js
126 lines (103 loc) · 3.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
let data=JSON.parse(localStorage.getItem("user_data"))||[];
class user{
constructor()
{
}
// this.name=a;
// this.id=b;
// }
// vadliteusername(name)
// {
// if(name.length>4)
// {
// return true;
// }
// else{
// alert("Enter correct Name");
// }
// }
validateemail(email)
{
if(email.length>8)
{
return true;
}
else
{
alert("Enter correct email");
}
}
validatephone(phone)
{
if(phone.length==10)
{
return true;
}
else
{
alert("Please enter valid phone no");
}
}
validatepassword(password)
{
if(password.length>=8)
{
return true;
}
else
{
alert("Please enter valid password");
}
}
sameemail(email)
{
let filterd=data.filter(function(elem)
{
return elem.email==email;
});
if(filterd.length>0)
{
alert("email alredy exits");
}
else
{
return true;
}
}
Signup(email,firstname,lastname,phone,password)
{
let isvadilite=false;
isvadilite=this.validateemail(email) &&this.validatephone(phone) && this.validatepassword(password) && this.sameemail(email) ;
if(isvadilite)
{
this.email=email;
this.password=password;
data.push(this);
console.log(data)
localStorage.setItem("user_data",JSON.stringify(data));
window.location.href="compdetails.html";
document.querySelector("#email").value=null;
document.querySelector("#firstname").value=null;
document.querySelector("#lastname").value=null;
document.querySelector("#phoneno").value=null;
document.querySelector("#password").value=null;
}
else
{
console.log("login not sucessfully");
}
}
}
document.querySelector("form").addEventListener("submit",datastorage);
function datastorage()
{
event.preventDefault();
// let form=document.querySelector("form");
let email=document.querySelector("#email").value;
let firstname=document.querySelector("#firstname").value;
let lastname=document.querySelector("#lastname").value;
let phone=document.querySelector("#phoneno").value;
let password=document.querySelector("#password").value;
let s=new user(email,phone,password);
s.Signup(email,firstname,lastname,phone,password);
}