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 forms = document.querySelectorAll("form"); // собираем формы | |
forms.forEach((form) => { | |
const validation = new JustValidate(form, { | |
errorFieldCssClass: ".is-invalid", | |
}); | |
validation | |
.addField("[name=username]", [ | |
{ | |
rule: "required", |
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 modal = document.querySelector(".modal"); //конст отвечающая за модальное окно | |
const modalDialog = document.querySelector(".modal-dialog"); //для отслеживания клика вне окна | |
document.addEventListener("click", (event) => { | |
if ( | |
event.target.dataset.toggle == "modal" || // если элемент содержит toggle modal ||(или) | |
event.target.parentNode.dataset.toggle == "modal" || // родительский элемент содержит | |
(!event.composedPath().includes(modalDialog) && //но если не(!) содержит и окно открыто, то закрываем | |
modal.classList.contains("is-open")) |