I'm working in a project in MVC, but I've been having trouble with the jquery validation. I have this event handler for the submit on jquery because I plan to use ajax on it.
$("#form-cart").on("submit",function(e){
// codes
});
But here's the case, even when the input is invalid, it still goes inside the anonymous function. The form is located inside a modal. But I saw some piece of code somewhere and tried it which is this.
$("#MyModal").on("submit","#form-cart",function (e){
//codes
});
Amazingly it works, and it doesn't go inside the anonymous function when the input is invalid. But yeah, here's the problem. From my understanding the, if the second one worked, the first one should also have worked, but it didn't. Can someone tell me the reason why? It really bottles me.. Thanks.