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.
Here's my effort so far:
$("form").submit(function() {
$(":radio").each(function(){
if($(this).val().length == 0) {
alert('Not selected all radios');
return false;
}
});
});
But it always ignores the if statement which will stop the submission, as if maybe $(this) isn't actually the value of the radio buttons?
Here's a jsFiddle: http://jsfiddle.net/aVVW9/
Any help would be much appreciated, thank you!