Form validation blocking the entire page

52 views Asked by At

I have a form in an mvc application.

If validation is triggered it disables every other button on the screen.

I would like to allow the user to navigate away from the page where the form is, but I don't know how to do that.

I tried to remove the validation itself, by commenting out the part of my code -on the controller - which validates the model but to no avail; i mean 'generally' this one:

if (ModelState.IsValid)
                {

}else
{ 
return viewmodel;
}

I wonder how to prevent the form validation from disabling every other button the page when it is triggered.

Many thanks.

1

There are 1 answers

1
Mateusz Marczukiewicz On BEST ANSWER

You can add class="cancel" to the buttons you do not want to be disabled, here is how JQuery.Validate selects the buttons:

this.find("input, button").filter(".cancel").click(function() {
    validator.cancelSubmit = true;
});