[jQuery] (validate plugin) dependency callback not being triggered
Hi
I've tried every way I can think of to use dependency to enable
additional elements to be required and have had no luck at all. I
simply want to enable "required" on a number of fields when a specific
radio button is selected and for it to be disabled when its not.
(These fields are hidden when the radio button is deselected)
I've tested the response from the functions and it appears correct but
after hours of staring at this I just can't figure it out.
Help.. please?
original code is on http://promotionalpenshop.com.au/testorder.php?p=4
though I may have changed it by the time you look at this.
So basically I've tried an inline function something like:
organisation:{required: function(element) {
return $(".payment_type:checked").val() == 'invoice');
}
}
- - - - - - - - - - - - - -
Setting a var to true/false when the radio button is clicked and
testing that:
var invoice;
$(".payment_type").change(function () {
if($(this).val() != 'paypal'){
$("#paybyinvoicefields").slideDown('slow');
invoice = true;
} else {
$("#paybyinvoicefields").slideUp('slow');
invoice = false;
}
organisation:{required: invoice}
- - - - - - - - - - - - - -
Using an enternal function
organisation:{required: invoiceme() }
function invoiceme() {
return ($(".payment_type:checked").val() == 'invoice')?
true : false;
}