I have a view with a form that uses the unobtrusive client side validation in asp.net mvc 3 to validate the form fields.
I also have a custom jquery script to submit the form via ajax
$(document).ready(function () {
$('#Submit').click(function (event) {
/* collect form input values as json*/
/* post the json data via ajax */
event.preventDefault();
event.stopPropagation();
});
});
My question is how can I change the order of the event handlers so that the asp.net mvc 3 client side validation gets called before my ajax form post handler so that the asp.net mvc handler can prevent my handler from getting called if there are any validation errors.
The problem I am having is that the asp.net mvc 3 unobtrusive javascript validation event handler is not triggered before my event handler.
By disabling the code at the end of my script that prevents further event propegation, I can see that the asp.net mvc 3 client side validation is indeed getting triggered after my handler is executed.