PIbd-22_Shabunov_O.A._Inter.../js/validation.js
2023-12-08 00:57:11 +04:00

17 lines
414 B
JavaScript

function validation() {
const forms = document.querySelectorAll("form.needs-validation");
forms.forEach((form) => {
form.addEventListener("submit", (event) => {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add("was-validated");
});
});
}
export default validation;