Hrmm, Jörn's blog comments said to use [validate] in the subject, but it looks like that got removed.
There was a bug in the code at the end of my post. Use this instead jQuery.validator.addMethod("visibleRequired", function(value, element) { return $(element).is(":hidden") || !this.optional(element); }, "This is required when visible"); jQuery.validator.addMethod("visibleRequiredFool", jQuery.validator.methods.visibleRequired, "My specific field is required"); On Sep 15, 11:32 am, Dr Stevens <daverstev...@gmail.com> wrote: > I'm using the validate plugin to validate ASP.NET webforms on the > client (I'd prefer to not use webforms, but for now I'm stuck with > it). Because I'm using webforms, I'm trying to get around using the > clientID of server controls. The metadata plugin works great, but I'd > prefer to not use it because it's gonna blow up my markup. > > Is there any way to utilize jQuery.validator.addClassRules to add > custom messages to a rule? Take the following for instance: > > jQuery.validator.addMethod("visible-required", function(value, > element) { > return $(element).is(":hidden") || !this.optional(element); > > }, "This is required when visible"); > > jQuery.validator.addClassRules("fool", { > visible-required: true, > lettersonly: true, > messages: { > visible-required: "My specific field must is required", > lettersonly: "Letters only fool!" > } > > }); > > On a slightly related note, is there any overhead associated with > adding custom validation methods specific to some field only to > override the default message? Take the following: > > jQuery.validator.addMethod("visible-required", function(value, > element) { > return $(element).is(":hidden") || !this.optional(element); > > }, "This is required when visible"); > > jQuery.validator.addMethod("visible-required-fool", > jQuery.validator.methods.visible - required, > "My specific field is required"); > > I saw your talk at the conference last weekend btw. Thanks