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.
Here are examples of using the jQuery Validation plugin with WebForms and emulating the concept of validation groups with it. It actually works pretty well once you smooth out a couple issues.
$("#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>