I would like to iterate over several (dynamic) switch groups using jQuery, and if someone had no choice, it throws an error and stops submitting the form.
Here are my efforts:
$("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 view, as if maybe $ (this) is not really the value of the switches?
Here's jsFiddle: http://jsfiddle.net/aVVW9/
Any help would be greatly appreciated, thanks!
Nick source share