📅  最后修改于: 2022-03-11 14:58:08.233000             🧑  作者: Mango
const enableValidation = () => {
// It will find all forms with the specified class in DOM, and
// make an array from them using the Array.from() method
const formList = Array.from(document.querySelectorAll(".form"));
// Iterate over the resulting array
formList.forEach((formElement) => {
formElement.addEventListener("submit", (evt) => {
// Cancel default behavior for each form
evt.preventDefault();
});
// Call the setEventListeners() function for each form,
// taking a form element as an argument
setEventListeners(formElement);
});
};
// Call the function
enableValidation();