-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.js
77 lines (64 loc) · 1.78 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
let form=document.querySelector("form");
let signup=JSON.parse(localStorage.getItem("signupdata"))||[];
form.addEventListener('submit', myfun )
function myfun(event){
event.preventDefault();
let signupobj={
username:document.querySelector("#username").value,
email:document.querySelector("#email").value,
password:document.querySelector("#password").value,
confirmpass:document.querySelector("#confirmpass").value,
// check:document.querySelector("robot").value,
}
function checkEmail(email){
let filter=signup.filter(function(el){
return email===el.email
});
if(filter.length>0){
return false;
}
else{
return true;
}
}
if(checkEmail(signupobj.email)===true){
if(signupobj.password===signupobj.confirmpass){
if(document.getElementById('robot').checked){
signup.push(signupobj);
localStorage.setItem("signupdata",JSON.stringify(signup));
alert("Signup successful")
url_redirect("login.html");
}else{
alert("confirm you are not robot by checking")
}
}
else{
alert("password not matched")
}
}
else{
alert("User already exist")
// window.location.reload()
url_redirect("login.html");
}
}
function url_redirect(url){
var X = setTimeout(function(){
window.location.replace(url);
return true;
},300);
if( window.location = url ){
clearTimeout(X);
return true;
} else {
if( window.location.href = url ){
clearTimeout(X);
return true;
}else{
clearTimeout(X);
window.location.replace(url);
return true;
}
}
return false;
};