How can I check if the radio button is checked or not by calling inline function of javascript?
<html>
<head>
<title>Test this</title>
<script>
var cnfrm= function(){
var x=document.getElementById('rdio2').value;
if (x==null || x=="")
{
confirm('are you sure?');
// return false;
// redirect to where you want
}
}
</script>
</head>
<body>
<form method=post action=index.html>
<br><input type=radio name=rdio id=rdio2 value=b>
<br><input type=radio name=rdio id=rdio2 value=c>
<br>
<input type=submit value=Submit onclick=cnfrm()>
</form>
</body>
</html>
Right now I am not getting anything and it ignore cnfrm
function, So I want it to execute so that I can check weather it is selected or not.