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

Reply via email to