Amit Dhamu

Software Engineer

Check If Radio Button Has Been Checked

Say you have a series of radio buttons on one page and for each group (with the same name), you want to ensure that at least one value has been selected. With jQuery you can.

var elements = {};
var count = 0;

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

$.each(elements, function() {

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

 form / radio / jquery

Use Browser As NotepadOpen External Links In New Tab

Show Comments