Stacking :last and :checked jQuery selectors together

Posted by jethomas on Stack Overflow See other posts from Stack Overflow or by jethomas
Published on 2010-04-07T19:28:19Z Indexed on 2010/04/07 19:33 UTC
Read the original article Hit count: 435

Filed under:
|
|
|
|

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');

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about validation