check if all radio box groups have a selection checked

by Akram kamal

HTML

<input type="radio" name="a" value="a1">
<input type=text size=10 name=txta1>
<br>
<input type="radio" name="a" value="a2">
<input type=text size=10 name=txta1>
<br>
<input type="radio" name="b" value="b1">
<input type=text size=10 name=txtb1>
<br>
<input type="radio" name="b" value="b2">
<input type=text size=10 name=txtb1>
<br>
<input type="radio" name="c" value="c1">
<br>
<input type="radio" name="c" value="c2">
<br>
<input name="submit" type="submit" value="Submit CSC Election Balot" class="next">
<br>
</p>
</div>

JavaScript

$(".next").click(function () {
    var empty = $(this).parent().find(":radio").filter(function(){
        return $("[name='"+this.name+"']:checked").val()===undefined
    })
    console.log(empty)
    if (empty.length) {
        alert('there were required fields that were not completed');
    }
});