-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript -2- Signup.js
68 lines (58 loc) · 2.79 KB
/
Script -2- 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
var managerData = [];
var signupSubmitButton = document.querySelector(".Signup-Submit-btn");
let flag = false;
if (localStorage.getItem("managerData")) {
managerData = JSON.parse(localStorage.getItem("managerData"))
}
// signupSubmitButton.onclick = () => {
signupSubmitButton.addEventListener("click", () => {
if (
document.querySelector(".fName-signup").value != "" &
document.querySelector(".sName-signup").value != "" &
document.querySelector(".userName-signup").value != "" &
document.querySelector(".password-signup").value != "" &
document.querySelector(".doBirth-signup").value != "" &
document.querySelector(".email-signup").value != "" &
document.querySelector(".loc-city-signup").value != "" &
document.querySelector(".loc-district-signup").value != ""
) {
for (let i = 0; i < managerData.length; i++) {
if (document.querySelector(".userName-signup").value === managerData[i].managerUsername) {
flag = true;
}
}
console.log(flag);
if (flag == false) {
const input = {
managerFirstName: document.querySelector(".fName-signup").value,
managerSecondName: document.querySelector(".sName-signup").value,
managerUsername: document.querySelector(".userName-signup").value,
managerPassword: document.querySelector(".password-signup").value,
managerDateOfBirth: document.querySelector(".doBirth-signup").value,
managerEmail: document.querySelector(".email-signup").value,
managerLocCountry: document.querySelector(".loc-country-signup").value,
managerLocCity: document.querySelector(".loc-city-signup").value,
managerLocDistrict: document.querySelector(".loc-district-signup").value,
}
managerData.push(input);
localStorage.setItem("managerData", JSON.stringify(managerData));
document.querySelector(".fName-signup").value = '';
document.querySelector(".sName-signup").value = '';
document.querySelector(".userName-signup").value = '';
document.querySelector(".password-signup").value = '';
document.querySelector(".doBirth-signup").value = '';
document.querySelector(".email-signup").value = '';
document.querySelector(".loc-city-signup").value = '';
document.querySelector(".loc-district-signup").value = '';
window.open("Index -1- Login.html", "_self");
}
else {
document.querySelector(".userName-signup").value = '';
alert("Username is already exist!");
flag = false;
}
}
else {
alert("Missing Inputs!");
}
})