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

Reply via email to