Radiobutton.checked is not working in Chrome, FireFox and Safari?

Posted by Mahe under JavaScript on 11/19/2012 | Points: 10 | Views : 4056 | Status : [Member] | Replies : 1
Hi,

Radiobutton.checked is not working in Chrome, FireFox6.x and Safari4.0 ?, but its working in IE 9.0
Please provide any suggession.




Responses

Posted by: Sandhyab on: 11/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Mahe,
Once try this code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function test() {
var rad = document.getElementById("radio1");
var rad2 = document.getElementById("radio2");
if (rad.checked == false && rad2.checked == false) {
alert("Please Select atleast one option");
}
}</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="radio" id="radio1" name="radio1" value="1" />
Value 1
<input type="radio" id="radio2" name="radio1" value="2" />
Value 2
<input type="button" id="btnClick" onclick="test()" value="ClickMe" />
</div>
</form>
</body>
</html>


This is validation for radio button if user doesnot select any thing.

Thanks & Regards

Mahe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response