views:

36

answers:

3

How to make a 'cancel' button not trigger the forms validation?

I'm using asp.net MVC with the jquery validation plugin.

A: 

Simply give it a cancel class:

<input type="submit" class="cancel" value="Submit without validation" />
Darin Dimitrov
A: 

You can define the validation group of the elements you're validating, as well as the buttons. http://www.dotnet-guide.com/validationgroups.html

Thiago Santos
A: 

Validation? Do you mean submission? If you want to cancel a form's submission, you have to return false on the form's submit event. See here:

http://jsfiddle.net/Bzz4J/

treeface