Jörn,

>This would make field2 required only if field1 is blank:
>
>rules: {
>  field2: { required: "#field1:blank" }
>}
>
>But I can't express that either field1 or field2 is required. How would
>I express that using pre/post-condition and implies?

I was thinking about this the other day, and I was thinking maybe the best
way to do this might be to allow a function to be declared.

rules: {
        field2: { required: function(field){ return (condition); }
}

This would at least add a lot of flexibility for how a field could be
defined. It might also be interested to have a "generic" (or "function")
rule which you can use to define a really form specific throw away
validation method.

However, one of the problems mapping a rule to a specific form field is it
still doesn't do a could job with either/or rules (i.e. either Field1 or
Field2 must be filled in.) Where do you throw the error message? Which field
do you attach the field to?

This is where having an API is a little more handle, because you really need
to write a customized validation rule and you probably want to handle error
throwing in a very specific way.

This is where exposing a way to hook into the onValidate event and having
ways to throw an error message programmatically would be handy.

-Dan

Reply via email to