I\'d like to loop through multiple (dynamic) radio button groups using jQuery, and if any haven\'t had a selection made, it throws up an error and stops the form submission.
$("form").submit(function() {
$(":radio", this).each(function(){
if(!this.checked) {
alert('Not selected all radios');
return false;
}
});
});
or
$("form").submit(function() {
if($(':radio:not(:checked)', this).length) {
alert('Not selected all radios');
return false;
}
});
Check this demo. Here for simplicity I wrap each radio group within a div having class radio_group and loop over them.