i have a form in a modal, when i click on submit button i want to prevent the form submission using vanilla js.
But if i use preventDefault();
like this code
form.addEventListener('beforeSubmit', function(event) {
event.preventDefault();
//Ajax submit
})
i get 2 submit events in my form end the form is sent…
Instead if a use jquery
$("#formCalendar").on('beforeSubmit', function (event) {
event.preventDefault();
//Ajax submit
return false;
})
It works…
Why with vanilla js doesn’t work?