Roland Roland - 1 month ago 9x
jQuery Question

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

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 they forgot to check a option.

I'm using the following code to get the values

var radio_button_val = $("input[name='html_elements']:checked").val();

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