Thats test code, nothing useful for an application. The code I posted
is what you'll want to use:

$("#myform").validate({
 rules: {
   username: {
     required: true,
     remote: {
       url: "checkusername.php",
       type: "post"
       data: {
         email: function() { return $("#email").val() }
       }
     }
   }
 }
});

Just put any option you need into that object literal and add
additional data to the data property.

You need the latest js file for it to work:
http://jqueryjs.googlecode.com/svn/trunk/plugins/validate/jquery.validate.js

Jörn

On Thu, Nov 27, 2008 at 12:29 PM, hcvitto <[EMAIL PROTECTED]> wrote:
>
> hi
> i just needed that option today!!
> for the moment i just found a not-very-good way out which works for
> me.
>
> Among the pages you suggested i found this:
>
> test("remote, customized ajax options", function() {
>        expect(2);
>        stop();
>        var v = $("#userForm").validate({
>                rules: {
>                        username: {
>                                required: true,
>                                remote: {
>                                        url: "users.php",
>                                        type: "post",
>                                        beforeSend: function(request, 
> settings) {
>                                                same(settings.type, "post");
>                                                same(settings.data, 
> "username=asdf&email=email.com");
>                                        },
>                                        data: {
>                                                email: function() {
>                                                        return "email.com";
>                                                }
>                                        },
>                                        complete: function() {
>                                                start();
>                                        }
>                                }
>                        }
>                }
>        });
>        $("#username").val("asdf");
>        $("#userForm").valid();
> });
>
> but i'm not sure how to use it..any help?
>
> Thanks Vitto
>
> On 25 Nov, 20:15, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> wrote:
>> With the 1.5 release you will be able to use this instead:
>>
>> $("#myform").validate({
>>   rules: {
>>     username: {
>>       required: true,
>>      remote: {
>>         url: "checkusername.php",
>>         type: "post"
>>         data: {
>>           email: function() { return $("#email").val() }
>>         }
>>       }
>>     }
>>   }
>>
>> });
>>
>> In other words, you can override all settings that $.ajax supports by
>> replacing the currentremote: "url" withremote: {url:"url"} and add
>> whatever you need.
>>
>> You can try it out now
>> (http://jqueryjs.googlecode.com/svn/trunk/plugins/validate/) or wait
>> for the next release.
>>
>> Feedback is welcome!
>>
>> Jörn
>>
>> On Thu, Nov 20, 2008 at 8:28 PM, Jörn Zaefferer
>>
>> <[EMAIL PROTECTED]> wrote:
>> > The current workaround I recommend is to use ajaxSend:
>>
>> > $().ajaxSend(function(e, xml, settings) {
>> >  $.extend(settings.data, { field2: $("#field2").val() });
>> > });
>>
>> > With the drawback that it gets applied to all ajax requests. Depends
>> > on your application if thats a problem and how to avoid it.
>>
>> > Jörn
>>
>> > On Thu, Nov 20, 2008 at 5:17 PM, SMaDeP <[EMAIL PROTECTED]> wrote:
>>
>> >> I want to make a duplicate check withremotevalidation, but I need an
>> >> additional parameter like the parent key
>> >> (no duplicate article numbers within one order)!
>>
>> >> does addMethod support async validation?
>> >> can I add an additional parameter to theremote-url? How?
>>
>> >> Thanks in advance,
>>
>> >> Stefan

Reply via email to