Using JQuery to check if no radio button in a group has been checked

后端 未结 8 1664
太阳男子
太阳男子 2020-12-12 15:42

I\'m sitting with a problem, I need to check with JQuery if no radio button within a radio button group has been checked, so that I can give the users an javascript error if

8条回答
  •  自闭症患者
    2020-12-12 16:04

    if ($("input[name='html_elements']:checked").size()==0) {
       alert('Nothing is checked!');
    }
    else {
      alert('One of the radio buttons is checked!');
    }
    

提交回复
热议问题