-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.js
70 lines (60 loc) · 2.13 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
document.querySelector("form").addEventListener("submit", usersubmit);
var registereduser = JSON.parse(localStorage.getItem("registereduser")) || [];
function usersubmit() {
event.preventDefault();
var name = document.querySelector("#name").value;
var email = document.querySelector("#email").value;
var re_email = document.querySelector("#confirm-email").value;
var password = document.querySelector("#password").value;
var re_password = document.querySelector("#confirm-password").value;
var mobile = document.querySelector("#mobile").value;
var obj = {
name: name,
email: email,
remail: re_email,
password: password,
repassword: re_password,
mobile: mobile,
}
// console.log(obj);
var dangerName = document.querySelector(".name");
var dangerEmail = document.querySelector(".email");
var dangerPassword = document.querySelector(".password");
var dangerRepassword = document.querySelector(".repassword");
var dangerReEmail = document.querySelector(".remail");
if (name == "") {
dangerName.style.display = "block";
} else {
dangerName.style.display = "none";
}
if (email == "") {
dangerEmail.style.display = "block";
} else {
dangerEmail.style.display = "none";
}
if (password == "") {
dangerPassword.style.display = "block";
} else {
dangerPassword.style.display = "none";
}
if (password != re_password) {
dangerRepassword.style.display = "block";
} else {
dangerRepassword.style.display = "none";
}
if (email != re_email) {
dangerReEmail.style.display = "block";
} else {
dangerReEmail.style.display = "none";
}
if (name!= "" && email!= "" && password!="" && re_password!="") {
/* console.log("sdfg") */
registereduser.push(obj);
localStorage.setItem("registereduser", JSON.stringify(registereduser));
alert('Account created successfully');
window.location.href = "signin.html";
} else {
/* window.localStorage.clear(); */
}
}
// localStorage.clear();