Check if all radio groups are checked

by Alvin Olavarrieta

JavaScript

var elements = {};
var count = 0;            

$(':radio').each(function () {
    elements[$(this).attr('name')] = true;
});

$.each(elements, function () {
    count++;
});

if ($(':radio:checked').length === count) {
    // All radio groups have a value selected
} else {
    // There is a radio button group with an empty value
}