Hi guys
I don't want to use a form button submit event, as I am using (
MVC reusable partial pages) so I want the jquery validation with control. In some instances these partial pages appear as modal popups
How do I focus on the required fields and enable the custom error messages.
Here is my code
$('#Button_Lists_Submit').click(ehi); // calls the validation code below
var Submit_Form = function () {
debugger
var data = $('#List_Form').serialize();
if ($('#List_Form').valid) {
ehi(); // call an ajax post here (which I already have in my code)
}
else {
return false;
form.focusInvalid() // focus on the form errors as this DOES NOT WORK
}
}
function ehi(e) {
e.preventDefault()
var fd = new FormData($("#List_Form")[0]);
var form = $('#List_Form');
form.validate();
if (!$('#List_Form').valid()) {
alert('Model is not valid -' + form.valid());
return false;
}