jQuery Validation plugin in ASP.NET Web Forms jQuery Validation plugin in ASP.NET Web Forms asp.net asp.net

jQuery Validation plugin in ASP.NET Web Forms


You can checkout the rules add function, but basically here's what you can do:

jQuery(function() {    // You can specify some validation options here but not rules and messages    jQuery('form').validate();     // Add a custom class to your name mangled input and add rules like this    jQuery('.username').rules('add', {         required: true,         messages: {             required: 'Some custom message for the username required field'         }     });});<input name="ctl00$ContentPlaceHolder1$tbUsername" type="text" id="ctl00_ContentPlaceHolder1_tbUsername" class="username" />

This way no need to worry about the crappy identifiers generated by the webforms engine.


$("#signupForm").validate({        rules: {                 <%= tbUsername.UniqueID %>: {                        required: true,                        minlength: 2                }, },        messages: {                 <%= tbUsername.UniqueID %>: {                        required: "Please enter a username",                        minlength: "username at least 2 characters"                },         });<asp:TextBox ID="tbUsername" runat="server"></asp:TextBox>