-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoot_Task6.html
More file actions
156 lines (155 loc) · 5.1 KB
/
Copy pathBoot_Task6.html
File metadata and controls
156 lines (155 loc) · 5.1 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Task6</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9"
crossorigin="anonymous"
/>
<style>
.bg-light-grey {
background-color: rgb(228, 227, 227);
}
.bg-light-red {
background-color: rgb(249, 115, 115);
}
</style>
<script>
function nameInfo() {
name = document.getElementById("name").value
if (name.length === 0) {
document.getElementById("name").classList.add("is-invalid")
return false
} else {
document.getElementById("name").classList.remove("is-invalid")
return true
}
}
function passwordInfo() {
password = document.getElementById("password").value
if (password.length === 0) {
document.getElementById("password").classList.add("is-invalid")
return false
} else {
document.getElementById("password").classList.remove("is-invalid")
return true
}
}
function eMail() {
email = document.getElementById("email").value
if (email.length === 0) {
document.getElementById("email").classList.add("is-invalid")
return false
} else {
document.getElementById("email").classList.remove("is-invalid")
return true
}
}
function hobbiesInfo() {
hobby = document.getElementById("hobbies").value
if (hobby === "nil") {
document.getElementById("hobbies").classList.add("is-invalid")
return false
} else {
document.getElementById("hobbies").classList.remove("is-invalid")
return true
}
}
function onSubmit() {
val1 = nameInfo()
val2 = eMail()
val3 = passwordInfo()
val4 = hobbiesInfo()
return val1 && val2 && val3 && val4
}
</script>
</head>
<body class="bg-light-grey">
<div class="p-5 m-5">
<div class="mx-auto" style="max-width: 500px">
<form onsubmit="return onSubmit()">
<div class="input-group p-2 m-3">
<div class="col-12">
<label for="name" id="name-label" class="mx-2 my-1">Name</label>
</div>
<div class="col-12">
<input
type="text"
class="form-control mx-2"
id="name"
onkeyup="nameInfo()"
/>
<div class="invalid-feedback mx-2">Name is required</div>
</div>
</div>
<div class="input-group p-2 m-3">
<div class="col-12">
<label for="email" id="email-label" class="mx-2 my-1"
>Email</label
>
</div>
<div class="col-12">
<input
type="email"
class="form-control mx-2"
id="email"
onkeyup="eMail()"
/>
<div class="invalid-feedback mx-2">Email is required</div>
</div>
</div>
<div class="input-group p-2 m-3">
<div class="col-12">
<label for="password" id="password-label" class="mx-2 my-1"
>Password</label
>
</div>
<div class="col-12">
<input
type="password"
class="form-control mx-2"
id="password"
onkeyup="passwordInfo()"
/>
<div class="invalid-feedback mx-2">Password is required</div>
</div>
</div>
<div class="input-group p-2 m-3">
<div class="col-12">
<label for="hobbies" id="hobbies-label" class="mx-2 my-1"
>Hobbies</label
>
</div>
<div class="col-12">
<select
class="form-select mx-2"
id="hobbies"
onchange="hobbiesInfo()"
>
<option value="nil">Please select a hobby</option>
<option value="cricket">Cricket</option>
<option value="football">Football</option>
</select>
</div>
</div>
<div class="input-group m-3 p-2">
<input
type="submit"
class="btn btn-danger col-12 mx-2"
value="Submit"
/>
</div>
</form>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm"
crossorigin="anonymous"
></script>
</body>
</html>