-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact-us.html
290 lines (205 loc) · 10.8 KB
/
contact-us.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
<div>
<div class="container-fluid">
<button id="modal-btn" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#model_3">
Launch
</button>
<!-- Modal -->
<div class="modal fade" id="model_3" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
aria-labelledby="model_3_label" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content normal-text">
<div class="modal-header">
<h5 class="modal-title" id="model_3_label">Form Submission!</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<div class="normal-text container fluid mt-5">
<div>
<div class="container card mb-3" style="max-width: 100%;">
<h5 class="card-title mt-4 mb-4 text-center text-white form_heading">Contact Us</h5>
<div class="row g-0">
<div class="col-md-4 p-2">
<img id="form_banner" src="images/contact_us2.jpg" class="img-fluid rounded" alt="...">
</div>
<div class="col-md-8">
<div class="card-body fs-6">
<form class="mt-5 p-3">
<div id="email_err" class="text-danger"></div>
<div class="form-floating">
<input type="email" class="form-control" id="email" aria-describedby="emailHelp"
placeholder="name@example">
<label for="email" class="form-label">Email address</label>
</div>
<div id="emailHelp" class="form-text mb-3">We'll never share your email with anyone
else.
</div>
<div id="name_err" class="text-danger"></div>
<div class="form-floating mb-3">
<input type="text" class="form-control" id="user_name" placeholder="pass">
<label for="user_name" class="form-label">Name</label>
</div>
<div>Purpose:</div>
<div id="purpose_err" class="text-danger"></div>
<div class="input-group mb-3">
<select id="drop_menu_purpose" class="form-select" id="inputGroupSelect04"
aria-label="Example select with button addon">
<option value="0" selected>Not specified</option>
<option value="complaint">Regarding a complaint</option>
<option value="bug fix">I have found a bug!</option>
<option value="business">Business purposes</option>
<option value="other">Other</option>
</select>
</div>
<div id="contact_err" class="text-danger"></div>
<div class="mb-3 form-floating">
<textarea class="form-control" placeholder="Leave a comment here"
id="contact_box"></textarea>
<label for="contact_box" class="form-label">Type here</label>
</div>
<div>Gender: </div>
<div id="gender_err" class="text-danger"></div>
<div class="mb-3">
<div class="form-check">
<input type="radio" name="gender" class="form-check-input order-1"
id="radio_check1" value="male">
<label class="form-check-label" for="radio_check1">Male</label>
</div>
<div class="form-check">
<input type="radio" name="gender" class="form-check-input order-2"
id="radio_check2" value="female">
<label class="form-check-label" for="radio_check2">Female</label>
</div>
<div class="form-check">
<input type="radio" name="gender" class="form-check-input order-3"
id="radio_check3" value="other">
<label class="form-check-label" for="radio_check3">Other</label>
</div>
</div>
<div class="mb-3 form-check">
<input type="checkbox" class="form-check-input" id="name_check">
<label class="form-check-label" for="name_check">Show Name</label>
</div>
<!-- <button onclick="validateForm()" type="button"
class="btn btn-primary fs-4 mt-3">Submit</button> -->
<button type="button"
class="btn btn-primary fs-4 mt-3">Submit</button>
</form>
<!-- <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.title = 'Contact Us | AMDT'
function validateForm() {
var email = document.getElementById("email");
var username = document.getElementById("user_name");
var purpose = document.getElementById("drop_menu_purpose");
var contact_box = document.getElementById("contact_box");
var gender = document.querySelector('input[name="gender"]:checked');
var nameCheck = document.querySelector('input[id="name_check"]:checked');
var valid_format = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var final_message = "";
var valid_points = 0;
if (email.value == "") {
$("#email_err").html("⚠ Email field cannot be empty")
} else {
if (email.value.match(valid_format)) {
$("#email_err").html("");
valid_points += 1;
} else {
$("#email_err").html("⚠ Invalid Email");
}
}
if (username.value == "") {
$("#name_err").html("⚠ Name field cannot be empty");
} else {
$("#name_err").html("");
valid_points += 1;
}
if (purpose.value == "0") {
$("#purpose_err").html("⚠ Please specify a purpose");
} else {
$("#purpose_err").html("");
valid_points += 1;
}
if (contact_box.value.trim() == "") {
$("#contact_err").html("⚠ This field cannot be empty");
} else {
if (contact_box.value.length > 500) {
$("#contact_err").html("⚠ Character limit is 500");
} else {
$("#contact_err").html("");
valid_points += 1;
}
}
if (gender === null) {
$("#gender_err").html("⚠ Please specify a gender");
} else {
$("#gender_err").html("");
valid_points += 1;
}
if (valid_points == 5) {
final_message += "<p>Dear " + username.value + ",</p>";
final_message += "<p>Your email address is " + email.value + ". ";
if (purpose.value == "other") {
final_message += "You haven't explicitly mentioned the purpose of your message by selecting '" + purpose.value + "'.</p>"
} else {
final_message += "You have selected '" + purpose.value + "' as the purpose of your message.</p>";
}
if (gender.value == "other") {
final_message += "<p>You haven't specified a gender by selecting '" + gender.value + "'. ";
} else {
final_message += "<p>Your gender is " + gender.value + ". ";
}
if (nameCheck === null) {
final_message += "You have chosen your name to be hidden</p>";
} else {
final_message += "You have chosen your name to be visible</p>";
}
final_message += "Your text message is: <br> <p>" + contact_box.value + "</p>";
$(".modal-body").html(final_message);
$("#modal-btn").click()
}
document.getElementsByClassName("form_heading")[0].scrollIntoView();
}
function card_pic_resize() {
if (screen.width > 991) {
$("#form_banner").attr("src", "images/contact_us_1.jpg");
} else if (screen.width <= 767) {
$("#form_banner").attr("src", "images/contact_us.jpg");
} else if (screen.width <= 991) {
$("#form_banner").attr("src", "images/contact_us_3.jpg");
}
}
$("#email").keyup(function () {
$("#email_err").html("");
});
$("#user_name").keyup(function () {
$("#name_err").html("");
});
$("#drop_menu_purpose").click(function () {
$("#purpose_err").html("");
});
$("#contact_box").keyup(function () {
$("#contact_err").html("");
});
$("input[name='gender']").change(function () {
$("#gender_err").html("");
});
$(window).resize(function () {
card_pic_resize();
});
card_pic_resize();
</script>