<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#btnSubmit').bind('click', function(){
var option = $('#option1').val();
if(option == ''){
alert('Answer empty');
}
return false;
});
});
</script>
…
<input type="radio" id="option1" name="option1 />
<input type="submit" name="btnSubmit" id="btnSubmit" value="submit" />
…
=> error click button submit not alert
you should modify you code a bit get the value of
:checkedradio button and if its not checked it means the value is empty and alert the answer is emptyfor example
here is the working example http://jsfiddle.net/L8VY8/