-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (32 loc) · 1.04 KB
/
index.js
File metadata and controls
45 lines (32 loc) · 1.04 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
//TOGGLE MOBILE NAV
function toggleMobileNav(){
const mobileIconMenu = document.getElementById('icon-menu');
const mobileIconCross = document.getElementById('icon-cross');
const navList = document.getElementById('nav-list');
mobileIconMenu.addEventListener('click', function(){
if(mobileIconMenu.style.display = 'block'){
mobileIconMenu.style.display = 'none';
mobileIconCross.style.display = 'block';
navList.classList.add('mobile-nav');
}
});
mobileIconCross.addEventListener('click', function(){
if(mobileIconCross.style.display = 'block'){
mobileIconCross.style.display = 'none';
mobileIconMenu.style.display = 'block';
navList.classList.remove('mobile-nav');
}
});
}
toggleMobileNav();
//FORM VALIDATION
function validateForm(){
const name = document.getElementById('name');
if(name.value === '' || name.match(/\d/)){
alret('You must enter a valid name')
}
}
const submit = document.getElementById('submit');
submit.addEventListener('click', function(){
validateForm();
});