Aaron Heimlich schrieb:
> On 2/8/07, *Jörn Zaefferer* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
> wrote:
>
>     Your feedback is highly appreciated! We should be able to create the
>     definite solution for jQuery form validation...
>
>
> A couple of things:
>
> -- You should document the fact that, by default ( i.e. when you're 
> not using the errorContainer or errorLabelContainer options) , error 
> messages are inserted into the DOM after the input they're associated with
Good point, I'll do that.
>
> -- Would it be possible to do something like this:
>
> $("#myform").validate({
>     rules: {
>          firstname: { required: true },
>          age: { number: true },
>          password: { min: 5, max: 32 }
>     },
>     messages {
>         password: {
>             min: "Please enter a password greater than 5 characters",
>             max: "Please enter a password less than 32 characters"
>         }
>     }
> });
No, only one message per field can be defined. But that is a limitation 
that seems to provide better usability anyway: It can be quite 
frustrating to enter a value, get an error message, correct the value, 
and getting a different error message. I think the better approach tells 
the user what it expects with one message. You example could be written 
as this:

$("#myform").validate({
    rules: {
         firstname: { required: true },
         age: { number: true },
         password: { rangeLength: [5, 32] }
    },
    messages {
        password: {
            rangeLength: "Please enter a password greater than {0} and 
less then {1} characters long",
        }
    }
});
>
> -- It would be nice if I could use this as a beforeSubmit callback in 
> this form plugin, rather than using the form plugin as a submit 
> callback for this
Mike offered to an option to the form plugin to directly pass the 
validation settings to the form plugin. That would be the most 
convienent approach.
>
> Otherwise, it's looking pretty good, Jorn!
Thanks!
>
> As an aside (and some shameless self promotion), you should NEVER use 
> JavaScript as your only validation method because you cannot rely on 
> JavaScript being available. Period[1].
>
> You should ALWAYS duplicate your validation using server side code, 
> that way there is no way for anyone to bypass your validation 
> routines. As it happens (here it comes....), I've been working on a 
> validation library in PHP[2] and one of my next goals is to be able to 
> export the rules and error messages (most likely as JSON) so they can 
> be used by JavaScript (like Jorn's). I was going to write my own 
> jQuery plugin, but perhaps I'll just write a small wrapper around this 
> one.
Absolutely! The long-time goal of this library was to create a 
serverside setup that generates the client-side rules based on the rules 
checked on the serverside, so you don't have to duplicate them, just 
what mentioned.

Please let me know when you implemented something, it would be great to 
have some examples to do that in different languages.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to