I want to check is there any radio button selected and if there is no selection to print some alert message.
The html code is:
<form action="" id="form" name="form" method="post">
<input type="radio" id="form_rd" name="form_rd" value="1"> 1
<input type="radio" id="form_rd" name="form_rd" value="2"> 2
<input type="radio" id="form_rd" name="form_rd" value="3"> 3
<button type="submit">send</button>
</form>
Jquery that I'm using for checking:
$("form#form").submit(function() {
if (!$("#form_rd").attr('checked')) {alert("not checked");return false;}
})
This jquery code is not working. What is the better solution for this radio button check?