checking at least one radio button is selected from each group (with jquery)
In the absence of any relationship between elements, or how to find the group names, I can only give you a pointer, but this should work (the check's triggered by clicking on the element of id="nextButton"
, but obviously this can be customised to any other appropriate event, such as $('form').submit()
, for example):
$(document).ready(
function(){
$('#nextButton').click(
function(){
var radioName = something; // use this if there's a relationship between the element
// triggering this check and the radio buttons
if ($('input[name='+ radioName +']:checked').length) {
// at least one of the radio buttons was checked
return true; // allow whatever action would normally happen to continue
}
else {
// no radio button was checked
return false; // stop whatever action would normally happen
}
}
);
}
);
$("input[@name='the_name']:checked").length;