Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dejanmarkovic/29baa437c8bd14a34fd6 to your computer and use it in GitHub Desktop.
Save dejanmarkovic/29baa437c8bd14a34fd6 to your computer and use it in GitHub Desktop.
check if all radio buttons are checked on the page
//checking if all radio butons are checked
$(":radio").change(function() {
//console.log('radio change ');
var names = {};
$(':radio').each(function() {
names[$(this).attr('name')] = true;
});
//console.dir(names);
var count = 0;
$.each(names, function() {
count++;
});
//console.log('count' + count);
//console.log('checked length' + $(':radio:checked').length );
//all checked
if ($(':radio:checked').length === count) {
alert("all answered");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment