日期:2014-05-20  浏览次数:20624 次

单选按钮怎么验证
在javascript中单选按钮怎么验证是否选中

------解决方案--------------------
好像是用这个 "checked "
判断这个
------解决方案--------------------
用JS实现..网上搜罗一下...
------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN "
"http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>
</head>
<script language= "javascript ">
function checkform()
{
if (document.form1.book.checked)
alert ( "book is checked ");
if (document.form1.game.checked)
alert ( "game is checked ");
}
</script>
<body>
<form name= "form1 " method= "post " action= " ">
<input type= "radio " name= "book " value= "radiobutton ">
<input name= "game " type= "radio " value= "radiobutton " checked>
<input type= "button " name= "Submit " value= "按钮 " onClick= "checkform() ">
</form>
</body>
</html>