-
Notifications
You must be signed in to change notification settings - Fork 0
/
summertraining.html
309 lines (271 loc) · 9.85 KB
/
summertraining.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html>
<head>
<title>Student Summer Training Signup Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
padding: 20px;
}
form {
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
padding: 30px;
width: 80%;
max-width: 600px;
}
h2 {
color: #333;
margin-bottom: 20px;
}
.label-bold {
font-weight: bold;
}
.form-container {
display: flex;
flex-wrap: wrap;
}
.column {
flex: 1;
padding: 0 20px;
box-sizing: border-box;
}
.form-container input,
.form-container select {
width: 100%;
margin-bottom: 10px;
padding: 10px 12px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 14px;
box-sizing: border-box;
}
.required::after {
content: " *";
color: red;
}
label {
display: block;
font-size: 14px;
margin-bottom: 5px;
}
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin-top: 20px;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.2s;
}
button:hover {
background-color: #45a049;
}
.checkbox-wrapper {
display: flex;
align-items: center;
}
@media (max-width: 768px) {
.form-container {
flex-direction: column;
}
.column {
width: 100%;
padding-bottom: 30px;
}
.column:last-child {
padding-bottom: 0;
}
}
.flex-training-row {
display: flex;
align-items: center;
gap: 10px;
}
.flex-training-row>div:first-child {
flex: 1;
margin-right: 10px;
}
.flex-training-row>div:last-child {
flex: 0;
}
.flex-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.flex-row>div {
flex: 1;
margin: 0 10px;
}
.days-row {
display: flex;
justify-content: space-between;
}
.day {
text-align: center;
}
.time-row {
display: flex;
justify-content: space-between;
}
.time {
display: flex;
flex-direction: column;
align-items: center;
}
</style>
<script>
function validateCheckboxes() {
const checkboxes = document.querySelectorAll('input[name="preferredTime"]');
const errorMessage = document.getElementById('errorMessage');
let isChecked = false;
for (let i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) {
isChecked = true;
break;
}
}
if (isChecked) {
errorMessage.style.display = 'none'; // hide error message
} else {
errorMessage.style.display = 'block'; // show error message
}
return isChecked;
}
function validateForm(e) {
const form = document.forms["studentForm"];
const studentName = form["studentName"].value;
const commitDays = form["commitDays"].value;
const commitMinutes = form["commitMinutes"].value;
if (studentName.trim() === "") {
alert("Student Name must not be empty.");
e.preventDefault();
return false;
}
if (commitDays === "") {
alert("# of Days Committed must be selected.");
e.preventDefault();
return false;
}
if (commitMinutes === "") {
alert("# of Minutes per day must be selected.");
e.preventDefault();
return false;
}
// Check if time is selected
if (!validateCheckboxes()) {
e.preventDefault();
return false;
}
// If all validation passes, the form will be submitted
return true;
}
</script>
</head>
<body>
<form name="studentForm" action="https://summersignup.stratenschemel.workers.dev" method="post" onsubmit="return validateForm(event)">
<div class="form-container">
<div class="column">
<label for="studentName" class="required label-bold">Student Name:</label>
<input type="text" id="studentName" name="studentName" required>
<div class="flex-row">
<div>
<label for="commitDays" class="required label-bold"># of Days Committed:</label>
<select id="commitDays" name="commitDays" required>
<option value="" selected>Select</option>
<option value="3-4">3-4</option>
<option value="4-5">4-5</option>
<option value="5-6">5-6</option>
<option value="6+">6+</option>
</select>
</div>
<div>
<label for="commitMinutes" class="required label-bold"># of Minutes per day:</label>
<select id="commitMinutes" name="commitMinutes" required>
<option value="" selected>Select</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
<option value="60">60</option>
</select>
</div>
</div>
<div class="flex-training-row label-bold">
<p>Participating in other summer training programs:</p>
<div class="checkbox-wrapper">
<input type="checkbox" id="otherPrograms" name="otherPrograms" value="Yes">
</div>
</div>
<label for="trainingDays" class="label-bold">Days Available for In-person Training:</label>
<div class="days-row">
<!-- Repeat for other days -->
<div class="day">
<div>Mon</div>
<input type="checkbox" id="monday" name="trainingDays" value="Mon">
</div>
<div class="day">
<div>Tues</div>
<input type="checkbox" id="tuesday" name="trainingDays" value="Tues">
</div>
<div class="day">
<div>Wed</div>
<input type="checkbox" id="wednesday" name="trainingDays" value="Wed">
</div>
<div class="day">
<div>Thurs</div>
<input type="checkbox" id="thursday" name="trainingDays" value="Thurs">
</div>
<div class="day">
<div>Fri</div>
<input type="checkbox" id="friday" name="trainingDays" value="Fri">
</div>
<div class="day">
<div>Sat</div>
<input type="checkbox" id="saturday" name="trainingDays" value="Sat">
</div>
<div class="day">
<div>Sun</div>
<input type="checkbox" id="sunday" name="trainingDays" value="Sun">
</div>
</div>
</div>
</div>
<div class="form-container">
<div class="column">
<label class="required label-bold">Preferred Training Time:</label>
<!-- Hidden input for validation message -->
<div id="errorMessage" style="color: red; display: none;">Preferred Training Time must be selected.</div>
<div class="time-row">
<div class="time">
<label for="morning">Morning</label>
<input type="checkbox" id="morning" name="preferredTime" value="Morning" onchange="validateCheckboxes()">
</div>
<div class="time">
<label for="afternoon">Afternoon</label>
<input type="checkbox" id="afternoon" name="preferredTime" value="Afternoon" onchange="validateCheckboxes()">
</div>
<div class="time">
<label for="evening">Evening</label>
<input type="checkbox" id="evening" name="preferredTime" value="Evening" onchange="validateCheckboxes()">
</div>
</div>
</div>
</div>
<button type="submit">Submit</button>
</form>
</body>
</html>