jQuery Determine if at least one radio button is checked in a radio group


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var radio_groups = {}
  2. $(":radio").each(function(){
  3. radio_groups[this.name] = true;
  4. })
  5.  
  6.  
  7. for(group in radio_groups){
  8. if ($(:radio[name="+group+"]:checked).length ==0) {
  9. //not checked
  10. } else {
  11. //checked
  12. }
  13.  
  14. }

URL: http://stackoverflow.com/questions/1165627/jquery-and-radio-button-groups

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.