Friday, 15 May 2015

jquery - Validation function is not working -



jquery - Validation function is not working -

i unable print error message please help me think unable phone call function please help total me new in jquery ..

$(document).ready(function () { $("form").submit(function () { $("#form1").validate({ rules: { name: "required", password: "required", repassword: "required", email: { required: true, email: true }, mobile: "required" }, messages: { name: "please specify name", password: "please specify password", repassword: "please specify repassword", email: { required: "we need email address contact you", email: "your email address must in format of name@domain.com" }, mobile: "please specify mobile number" }, showerrors: function (errormap, errorlist) { if (errorlist.length) { $("span").html(errorlist[0].message); } } }); }); });

this front end end code calling validate on form submit-----

<form id="form1" action="" method="post" runat="server"> <div> <asp:label id="heading" runat="server" text="validation form"></asp:label> <span id="res"></span> <table> <tr> <td class="deslabel"> <asp:label id="label1" runat="server" text="name"></asp:label> </td> <td> <asp:textbox id="textbox1" runat="server" cssclass="destext" name="name"></asp:textbox> </td> </tr> <tr> <td class="deslabel"> <asp:label id="label2" runat="server" text="password"></asp:label> </td> <td> <asp:textbox id="textbox2" runat="server" cssclass="destext" name="password"></asp:textbox> </td> </tr> <tr> <td class="deslabel"> <asp:label id="label3" runat="server" text="resetpassword"></asp:label> </td> <td> <asp:textbox id="textbox3" runat="server" cssclass="destext" name="repassword"></asp:textbox> </td> </tr> <tr> <td class="deslabel"> <asp:label id="label4" runat="server" text="email"></asp:label> </td> <td> <asp:textbox id="textbox4" runat="server" cssclass="destext" name="email"></asp:textbox> </td> </tr> <tr> <td class="deslabel"> <asp:label id="label5" runat="server" text="mobile"></asp:label> </td> <td> <asp:textbox id="textbox5" runat="server" cssclass="destext" name="mobile"></asp:textbox> </td> </tr> <tr align="center"> <td colspan="2"> <asp:button id="button1" runat="server" text="validate" cssclass="destext" /> </td> </tr> </table> </div> </form>

you need phone call validate on load, not on submit. if setup validation on submission of form its' late validate it.

$(document).ready(function() { $("#form1").validate({ // rest of settings... }); });

jquery asp.net

No comments:

Post a Comment