internet-programming/lab2/js/validation.js

16 lines
459 B
JavaScript
Raw Normal View History

2023-11-02 21:33:55 +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");
});
}
}
2023-11-03 11:28:48 +04:00
export default validation;