开发者

jquery validation for specific button onclick

i am using jquery client side validation in asp.net.

the problem i a开发者_JS百科m facing now is that whenever i click any button in a page it causes validation rather than for specific button alone.

how to resolve this .?

thank you


Suppose you have two buttons SubmitButton and CancelButton and you do not want to CancelButton to fire validation plugin, just give CssClass="cancel" for CancelButton

    <asp:Button ID="CancelButton" runat="server" 
            Text="Return to List" 
            CssClass="cancel" />


You want to use event.preventDefault().

http://api.jquery.com/event.preventDefault/

$("button").click(function(event) {
    event.preventDefault();
    // do stuff here
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜