-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
243 lines (209 loc) · 6.19 KB
/
script.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
241
242
243
var type2 = document.getElementById("type2");
var typewriter = new Typewriter(type2, {
loop: true,
});
typewriter.typeString("Geeks Of Canara").pauseFor(2500)
.deleteAll()
.typeString('Geeks Of Canara')
.pauseFor(2500)
.deleteAll()
.typeString('Geeks Of Canara')
.pauseFor(2500)
.start();
var btn1 = document.querySelector("#club_btn_1");
var btn2 = document.querySelector("#club_btn_2");
var btn3 = document.querySelector("#club_btn_3");
var btn4 = document.querySelector("#club_btn_4");
var active = btn1;
var items = [btn1, btn2, btn3, btn4];
var i = 1;
var interval = setInterval(() => {
if (i == items.length) {
items[0].click();
i = 1;
} else {
items[i].click();
i++;
}
}, 5000);
var cards = document.querySelectorAll('.our_club .card')
const changeContent = function(id){
id = parseInt(id)-1
cards[id].style.display = 'flex';
for(var i=0; i<cards.length; i++){
if(i!=id){
cards[i].style.display = 'none';
}
}
}
btn1.addEventListener("click", (e) => {
active.classList.remove("active");
btn1.classList.add("active");
active = btn1;
changeContent(e.currentTarget.getAttribute("data-id"));
if (e.isTrusted) {
clearInterval(interval);
}
});
btn2.addEventListener("click", (e) => {
active.classList.remove("active");
btn2.classList.add("active");
active = btn2;
changeContent(e.currentTarget.getAttribute("data-id"));
if (e.isTrusted) {
clearInterval(interval);
}
});
btn3.addEventListener("click", (e) => {
active.classList.remove("active");
btn3.classList.add("active");
active = btn3;
changeContent(e.currentTarget.getAttribute("data-id"));
if (e.isTrusted) {
clearInterval(interval);
}
});
btn4.addEventListener("click", (e) => {
active.classList.remove("active");
btn4.classList.add("active");
active = btn4;
changeContent(e.currentTarget.getAttribute("data-id"));
if (e.isTrusted) {
clearInterval(interval);
}
});
var toggler = document.querySelector(".navbar-toggler")
var navLinks = document.querySelectorAll(".nav-link")
navLinks.forEach(nav=>{
nav.addEventListener("click",()=>{
console.log("clicked")
toggler.click();
})
})
// Contact us - Form validation
const nameError = document.getElementById('name-error');
const emailError = document.getElementById('email-error');
const subjectError = document.getElementById('subject-error');
const messageError = document.getElementById('message-error');
const submitError = document.getElementById('submit-error');
var submit=document.getElementById('submit');
function validateName(){
var name = document.getElementById('name').value;
if(name.length==0){
nameError.innerHTML="Name field required !";
return false;
}
if(!name.match(/^[A-Za-z]*\s{1}[A-Za-z]*/) || name.length<3){
nameError.innerHTML="Enter full name !";
return false;
}
nameError.innerHTML="";
submit.disabled=false;
submitError.innerHTML= "";
return true;
}
function validateEmail(){
var email=document.getElementById('email').value;
if(email.length==0){
emailError.innerHTML="Email field required !";
return false;
}
if(!email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/)){
emailError.innerHTML="Invalid email !";
return false;
}
emailError.innerHTML="";
submit.disabled=false;
submitError.innerHTML= "";
return true;
}
function validateSubject(){
var subject=document.getElementById('subject').value;
if(subject.length==0){
subjectError.innerHTML="Subject field required !";
return false;
}
if(subject.match(/^[A-Za-z0-9]*\s{1}[A-Za-z0-9]*$/)){
subjectError.innerHTML="Invalid subject !";
return false;
}
subjectError.innerHTML="";
submit.disabled=false;
submitError.innerHTML= "";
return true;
}
function validateMessage(){
var message=document.getElementById('message').value;
var required=30;
var remaining=required - message.length;
if(message.length==0){
messageError.innerHTML="Message field required !";
return false;
}
if(remaining>0){
messageError.innerHTML= remaining+" more characters required !";
return false;
}
messageError.innerHTML="";
submit.disabled=false;
submitError.innerHTML= "";
return true;
}
function validateForm(e){
nameError.innerHTML = "";
emailError.innerHTML = "";
subjectError.innerHTML = "";
messageError.innerHTML = "";
flag=false;
if(validateName()||validateEmail()||validateSubject()||validateMessage()){
submitError.innerHTML= "";
flag=true;
}
else if(!validateName()||!validateEmail()||!validateSubject()||!validateMessage()){
submitError.innerHTML= " Please fill in the required fields";
if(!validateName()){
nameError.innerHTML="Name field required !";
submitError.innerHTML= " Please fill in the required fields";
}
if(!validateEmail()){
emailError.innerHTML="Email field required !";
submitError.innerHTML= " Please fill in the required fields";
}
if(!validateSubject()){
subjectError.innerHTML="Subject field required !";
submitError.innerHTML= " Please fill in the required fields";
}
if(!validateMessage()){
messageError.innerHTML="Message field required !";
submitError.innerHTML= " Please fill in the required fields";
}
}
return flag;
}
var view_more_coding = document.getElementsByClassName("vmcard");
var vmc = document.getElementsByClassName("view-more");
var vmclose = document.getElementsByClassName("vmclose");
vmc[0].addEventListener("click", () => {
view_more_coding[0].style.display = "flex";
});
vmc[1].addEventListener("click", () => {
view_more_coding[1].style.display = "flex";
});
vmc[2].addEventListener("click", () => {
view_more_coding[2].style.display = "flex";
});
vmc[3].addEventListener("click", () => {
view_more_coding[3].style.display = "flex";
});
vmclose[0].addEventListener("click", () => {
view_more_coding[0].style.display = "none";
});
vmclose[1].addEventListener("click", () => {
view_more_coding[1].style.display = "none";
});
vmclose[2].addEventListener("click", () => {
view_more_coding[2].style.display = "none";
});
vmclose[3].addEventListener("click", () => {
view_more_coding[3].style.display = "none";
});