The method has to return something else then undefined. You can use the
remote-method instead, it allows you to do remote checks:
http://docs.jquery.com/Plugins/Validation/Methods/remote

Jörn

On Wed, Oct 21, 2009 at 2:12 PM, Samuurai <djbe...@gmail.com> wrote:

>
> Hi,
>
> This is my first attempt at using addMethod and it's always returning
> true, for some reason.
>
> This is placed outside of document.ready
>
> jQuery.validator.addMethod("checkemail", function(email) {
>        var email = $('#email').val();
>                $.post("user/checkemail", { "email" : email },
>                function(data){
>                                if(data.exists == "1")
>                                {
>                                        return true;
>                                }
>                }, "json" );
>        }, 'This email already has already been registered');
>
> and in the validate() method, I'm calling the function like this:
>
> rules:{
>        email: {
>                required: true,
>                email: true,
>                checkemail: true
>                }
> }
>
> Is there anything obvious i'm doing wrong here?
>
> Thanks!

Reply via email to