asp.net mvc 3 - MVC3 C# Disabling the Validation Messages on Cancel -


i have mvc2 c# .net web app. using built in mvc3 validation using domain class properties [required(errormessage = "start required.")] , in html @html.validationmessagefor(model => model.startfrom)

however, when submit page using cancel button, validation fired stating "start required" , therefore not exiting page. how can disable validation on cancel button? or submit page without firing validation?

i think need override default behaviour of submit button i.e., cancel button in case.

say have cancel button this:

<input type="submit" id="btncancel" value="cancel"/> 

now write jquery override default behaviour

$(function(){     $('#btncancel').click(function(e){         e.preventdefault();         //or can return false method.         //return false;     }); }); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -