Stacking :last and :checked jQuery selectors together
- by jethomas
I'm trying to setup custom validation for a checkbox. I have 7 checkboxes each with the same name and I want to identify if the last one is checked. This is the code I have and I know its wrong, could anyone shed some light on how to properly stack the :last and :checked selectors together?
$.validator.addMethod('ObserverOtherBox',function(v, e) {
return ($('[[name="4_observers"]:last]:checked').length == 1) && ($('[name="4_observerstxt"]').length == 0) ;
}, 'Please enter the other observers');