-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuggy Website.html
107 lines (102 loc) · 4.11 KB
/
Buggy Website.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins">
<link rel="stylesheet" href="styles/style.css">
<title>Buggy Website</title>
</head>
<body>
<div id="wrapper">
<form action="" name="signup" id="form">
<h3>Sign Up</h3>
<div class="form-group">
<label for="">First Name<span>*</span></label>
<input type="text" placeholder="Enter First Name" id="first-name">
</div>
<div class="form-group">
<label for="">Last Name<span>*</span></label>
<input type="text" placeholder="Enter Last Name" id="last-name">
</div>
<div class="form-group">
<label for="">Father Name<span>*</span></label>
<input type="text" placeholder="Enter Father Name" required id="father-name">
</div>
<div class="form-group">
<label for="">Email<span>*</span></label>
<input type="email" placeholder="Enter Email" id="email" required>
</div>
<div class="form-group">
<label for="">Phone Number<span>*</span></label>
<input type="number" placeholder="Enter Phone Number" required>
</div>
<div id="radio-wrapper" class="form-group">
<div>Gender</div>
<input type="checkbox" name="gender">
<label for="">Male</label>
<input type="checkbox" name="gender">
<label for="">Female</label>
</div>
<div class="form-group">
<label for="">Date of birth<span>*</span></label>
<input type="date" placeholder="Enter Date of birth">
</div>
<div class="form-group">
<label for="">Country</label>
<input type="text" placeholder="Enter Country">
</div>
<div class="form-group">
<label for="">City</label>
<input type="text" placeholder="Enter City">
</div>
<div class="form-group">
<button type="submit" id="submit-btn">Agree and Join</button>
</div>
</form>
</div>
<script>
const submit = false;
const submitButton = document.querySelector("#submit-btn");
const firstNameInput = document.querySelector("#first-name");
const lastNameInput = document.querySelector("#last-name");
const emailInput = document.querySelector("#email");
const fatherNameInput = document.querySelector("#father-name");
firstNameInput.addEventListener("keydown", (event) => {
if(event.code == "Space") {
alert("Empty spaces are not allowed")
return false;
}
});
const onSubmit = (event) => {
event.preventDefault();
const firstName = firstNameInput.value;
const lastName = lastNameInput.value;
const email = emailInput.value;
const fatherName = fatherNameInput.value;
if(!firstName.trim()) {
alert("First name can't be empty");
return false;
}
if(!fatherName.trim()) {
alert("Name can't be empty");
return false;
}
if(!email.trim()) {
alert("email is required");
window.location = "404.html";
return false;
}
localStorage.setItem("fullName", firstName + " " + lastName);
localStorage.setItem("loggedin", 1);
window.location = "dashboard.html";
}
const onDoubleClick = (event) => {
window.location = "404.html";
}
submitButton.addEventListener("dblclick", onDoubleClick);
submitButton.addEventListener("click", onSubmit);
</script>
</body>
</html>