Internet-programming-Pibd-2.../js/validation.js

16 lines
459 B
JavaScript
Raw Normal View History

2023-12-07 22:24:21 +04:00
function validation() {
const forms = document.querySelectorAll("form.needs-validation");
for (let i = 0; i < forms.length; i += 1) {
const form = forms[i];
form.addEventListener("submit", (event) => {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add("was-validated");
});
}
}
export default validation;