Fantastic!!! I got it working.. my first ever ajax request.. :P Thanks Jorn for this great plugin.
For other readers, have your remote script return "true" or "false" - no need for JSON. Here's my working code. rules:{ email: { required: true, email: true, remote: { url: "user/checkemail", type: "post", data: { email: function() { return $("#email").val(); } } } } On Oct 21, 1:23 pm, Jörn Zaefferer <joern.zaeffe...@googlemail.com> wrote: > 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!