-
Notifications
You must be signed in to change notification settings - Fork 0
/
scriptx.js
240 lines (210 loc) · 7.23 KB
/
scriptx.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
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
// Shows loading screen till the webpage is loading //
{
setTimeout(window.onload = function loader() {
document.getElementById('loading').style = "display:none"
}, 1569)
}
// NAV-BAR HIDE ON SCROLL DOWN //
{
var Scrollpos = window.pageYOffset;
window.onscroll = function() {
var newScrollPos = window.pageYOffset;
if (Scrollpos > newScrollPos) {
document.getElementById("navx").style.top = "0";
} else {
document.getElementById("navx").style.top = "-60px";
}
Scrollpos = newScrollPos;
}
}
// Menubar toggle in small screen//
{
$("#barbar").click(() => $("#menu-list").slideToggle(500))
// Menubar re-sets to default style when resized.
$(window).resize(() => {
if ($(window).innerWidth() > 768) {
$("#menu-list").removeAttr("style");
}
})
// Menubar dissappear when scrolling the page.
$(window).scroll(() => {
if ($(window).innerWidth() < 769) {
$("#menu-list").slideUp(500);
}
})
// Hide Menu when clicked anywhere outside the menu-block
// var mCon = $("#menu-list")
// $(window).mouseup((e) => {
// if ($(window).innerWidth() < 769 && !mCon.is(e.target) && mCon.has(e.target).length === 0) {
// mCon.slideUp(500);
// }
// })
//Contradicts with Menubar toggle button
}
// Scroll to Top button //
{
$(window).scroll(() => {
if ($(this).scrollTop() > 100) {
$("#srl-up").fadeIn()
} else {
$("#srl-up").fadeOut()
}
})
$("#srl-up").click(() => $(window).scrollTop(0))
}
// IMAGE SLIDER ABOUT PAGE //
{
var arr_image = ['a-i0', 'a-i1', 'a-i2', 'a-i3']
var i = 0;
function nextImage() {
i++;
if (i >= arr_image.length) {
i = 0;
document.getElementById('box').innerHTML = `<img src="images/${arr_image[i]}.jpg" alt="Team Kosmos eSports">`
} else {
document.getElementById('box').innerHTML = `<img src="images/${arr_image[i]}.jpg" alt="Team Kosmos eSports">`
}
}
function prevImage() {
i--;
if (i < 0) {
i = arr_image.length - 1;
document.getElementById('box').innerHTML = `<img src="images/${arr_image[i]}.jpg" alt="">`
} else {
document.getElementById('box').innerHTML = `<img src="images/${arr_image[i]}.jpg" alt="">`
}
}
setInterval(nextImage, 3690);
}
// FORM VALIDATION //
{
var nameExp = /^[a-zA-Z\s]+$/;
var numExp = /^[0-9]*$/;
var emailExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var passExp = /^[a-zA-Z]\w{3,14}$/;
// var alphaNumExp = /^[a-zA-Z0-9]+$/;
// var alphaNumSpaceExp = /^[a-zA-Z0-9\s]+$/;
var dateExp = /((0?[13578]|10|12)(-|\/)((0[0-9])|([12])([0-9]?)|(3[01]?))(-|\/)((\d{4})|(\d{2}))|(0?[2469]|11)(-|\/)((0[0-9])|([12])([0-9]?)|(3[0]?))(-|\/)((\d{4}|\d{2})))/;
var addressExp = /^[a-zA-Z0-9\s,.'-]{3,}$/;
function validate() {
// First name verification
var x = document.getElementById('f-name').value;
if (x == "") {
document.getElementById('error-fname').innerHTML = "* Required";
document.getElementById('f-name').focus();
return false;
} else if (!x.match(nameExp)) {
document.getElementById('error-fname').innerHTML = "Enter Correct Name";
document.getElementById('f-name').focus();
return false;
} else {
document.getElementById('error-fname').innerHTML = "";
}
// Last Name verification USING JQUERY
var x = $('#l-name').val();
if (x == "") {
$('#error-lname').html("* Required");
$('#l-name').focus();
return false;
} else if (!x.match(nameExp)) {
$('#error-lname').html("Name in correct format");
$('#l-name').focus();
return false;
} else {
$('#error-lname').html("");
}
// Email verification
var x = document.getElementById('email').value;
if (x == "") {
document.getElementById('error-email').innerHTML = "* Required";
document.getElementById('email').focus();
return false;
} else if (!x.match(emailExp)) {
document.getElementById('error-email').innerHTML = "Enter Correct Mail";
document.getElementById('email').focus();
return false;
} else {
document.getElementById('error-email').innerHTML = "";
}
// Phone no verification
var x = document.getElementById('phone').value;
if (x == "") {
document.getElementById('error-phone').innerHTML = "* Required";
document.getElementById('phone').focus();
return false;
} else if (!x.match(numExp)) {
document.getElementById('error-phone').innerHTML = "Enter Correct Number";
document.getElementById('phone').focus();
return false;
}
if (x.length < 10 || x.length > 13) {
document.getElementById('error-phone').innerHTML = "Contact No. should be between 10 & 13 digits";
document.getElementById('phone').focus();
return false;
} else {
document.getElementById('error-phone').innerHTML = "";
}
// Date entry validation
var x = document.getElementById('dob').value;
if (x == "") {
document.getElementById('error-dob').innerHTML = "* Required";
document.getElementById('dob').focus();
return false;
} else if (!x.match(dateExp)) {
document.getElementById('error-dob').innerHTML = "Select a date";
document.getElementById('dob').focus();
return false;
} else {
document.getElementById('error-dob').innerHTML = "";
}
// Gender verification
var x = document.getElementsByName('gen');
if (!(x[0].checked || x[1].checked || x[2].checked)) {
document.getElementById('error-gender').innerHTML = "Select Gender";
document.getElementById('error-gender').focus();
return false;
} else {
document.getElementById('error-gender').innerHTML = "";
}
//Selection box (select country) USING JQUERY
var x = $('#country').val();
if (x == "") {
$('#error-country').html("* Select your country");
$('#error-country').focus();
return false;
} else {
$('#error-country').html("");
}
// Address verification
var x = document.getElementById('user-address').value;
if (x == "") {
document.getElementById('error-address').innerHTML = "* Required";
document.getElementById('user-address').focus();
return false;
} else if (!x.match(addressExp)) {
document.getElementById('error-address').innerHTML = "Type Address in correct format";
document.getElementById('user-address').focus();
return false;
} else {
document.getElementById('error-address').innerHTML = "";
}
// Checkbox checked or not for terms & conditions
// var x = $("#toc");
// if (!x.checked) {
// $("#error-toc").html(" * Required");
// $("#toc").focus();
// return false;
// } else {
// $("#error-toc").html(" ");
// return true;
// }
var x = document.getElementById("toc");
if (!x.checked) {
document.getElementById("error-toc").innerHTML = " * Required";
document.getElementById("toc").focus();
return false;
} else {
document.getElementById("error-toc").innerHTML = "";
}
}
}