-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup.js
83 lines (76 loc) · 2.47 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
document.querySelector("#submit").addEventListener("click",save);
var arr=JSON.parse(localStorage.getItem("data"))||[];
function save(){
var name= document.getElementById("name").value;
var email=document.getElementById("email").value;
var password= document.getElementById("password").value;
var check= document.getElementById("check").checked;
obj={
name:name,
email:email,
password:password,
}
count1=0;
if(email!=""){
for(var i=0;i<email.length;i++){
if(email[i]=="@"){
count1++
}
}
if(count1==0){
document.querySelector("#alert2").innerText="Please enter email in the format of *****@***.com";
}
}
if(name!=""&&email!=""&&password!=""&&check==true){
var upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lower="abcdefghijklmnopqrstuvwxyz";
var numeric="0123456789";
var symbol="~!@#$%^&*";
countu=0;countl=0;countn=0;counts=0;
for(i=0;i<password.length;i++){
for(var j=0;j<upper.length;j++){
if(password[i]==upper[j]){
countu++
}
if(password[i]==lower[j]){
countl++
}
if(password[i]==numeric[j]){
countn++
}
if(password[i]==symbol[j]){
counts++
}
}
}
if(countn<1||counts<1||countl<1||countu<1){
let alert= document.getElementById("alert3");
alert.innerText="Password must contain at least one uppercase letter,one lowercase letter,one digit and atleast one symbol"
}
if(countn>0&&counts>0&&countl>0&&countu>0&&count1>0){
if(password.length>7){
arr.push(obj)
localStorage.setItem("data",JSON.stringify(arr));
window.location.href = "login.html";
}
else{
let alert= document.getElementById("alert3");
alert.innerText="Password must be of atleast 8 characters"
}
}
}
else{
if(name==""){
document.querySelector("#alert1").innerText="Please enter your full name";
}
if(email==""){
document.querySelector("#alert2").innerText="Please enter your email";
}
if(password==""){
document.querySelector("#alert3").innerText="Please enter your password";
}
if(check==false){
document.querySelector("#alert4").innerText="Please accept Terms&Conditions";
}
}
}