I may be misunderstanding something, but what does this do that
$.validator.addMethod[1] doesn't?

[1]
http://jquery.bassistance.de/api-browser/plugins.html#jQueryvalidatoraddMethodStringFunctionString

On 4/19/07, Dan G. Switzer, II <[EMAIL PROTECTED]> wrote:


Jörn,

>Sorry, my example was a bit misleading. So far you can't pass a function
>as a rule, only as a value to required.
>supported: field: { required: function() {} }
>not supported: field: function() {}
>
>By adding support for the latter, you could do almost everything, but
>I'm not yet sure how it should actually work.

Well, my idea was that you could define a key in the rules object that is
a
function.

Then you could do something like:

var result =
        (typeof rule.value == "function" ) ?
                rule.value(
                        jQuery.trim(element.value), element,
rule.parameters
                )
        :
                jQuery.validator.methods[rule.method](
                        jQuery.trim(element.value), element,
rule.parameters

                )
        ;

I think if you made this change, then you could do:

rules = {
        field2: {
                email: true,
                myRule: function(){
                        true
                }
        }
},

message = {
        field2: {
                myRule: "Hey, I always fail!"
        }
}

I didn't dig too deeply in the code, so I may have it wrong, but I think
you
can see what I was getting at.

-Dan




--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com

Reply via email to