You have to modify your method to make it optional, like this: $.validator.addMethod("dropdown", function(value, element) { return this.optional(element) || element.selectedIndex>0; },'');
Jörn On Wed, Nov 5, 2008 at 6:23 PM, Pezza <[EMAIL PROTECTED]> wrote: > > Hi > > Using JQuery + Validate plugin. When I create a new custom rule using > a call to addMethod then use required:"myradio:checked" it will always > trigger the validation to fail even if the radio is unchecked. This > behaviour does not occur when you use the built in validation methods. > > $.validator.addMethod("dropdown", function(value, element) { > return element.selectedIndex>0; > },''); > > $("#myform").validate({ > rules:{ > mydropdown:{required:"#myradio:checked",dropdown:true} > } > }); > > So even when #myradio is NOT checked the rule is saying that > validation has failed. What I would like to happen would be for > validated to check the "required" rule first, if the radio is > unchecked then it should return valid and drop calls to any other > validation methods. > > Any ideas or have I got something backwards. > > Thanks >