I want to know if submit gets called if my form data are not valid in html5 validation. For example I have a form id personal_info.
I use the following block to get on submit event :
$("#personal_info").submit(function(event) { event.preventDefault(); saveData("personal_info"); }); function saveData(formName){ console.log("test"); } Is is the default behavior that the function saveData gets called on submit because even if my form is not valid the function gets called.
How to prevent submit function from being called if my form is invalid?
if(!$(this).valid()) return;saveData, I'd say it's very default JS behavior to execute that function.