Last active
February 26, 2020 10:49
-
-
Save sobchenyuk/94f491c9b933093653f4747e47f57dc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{ | |
const filterForm = document.querySelector('#filterForm'); | |
function submitFunc(e) { | |
const field = [ | |
'region', 'towns', 'areas' | |
]; | |
let select = filterForm.querySelectorAll('select'); | |
let i = 0; | |
let result = select.length; | |
field.forEach(function(item, i, field) { | |
if(select[i].classList.contains('visible')){ | |
if (select[i].value === "false") { | |
select[i].classList.add('uk-form-danger'); | |
} else { | |
select[i].classList.remove('uk-form-danger'); | |
} | |
} | |
}); | |
for ( ; i < result; i++ ) { | |
if(select[i].classList.contains('uk-form-danger')){ | |
e.preventDefault(); | |
} | |
} | |
} | |
filterForm.addEventListener('submit', submitFunc) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment