<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>text</title>
<script>
var chk = 0;
window.onload=function (){
var chkObjs = document.getElementsByName("radio");
for(var i=0;i<chkObjs.length;i++){
if(chkObjs[i].checked){
chk = i;
break;
}
}
}
function check_radio(){
var chkObjs = document.getElementsByName("radio");
for(var i=0;i<chkObjs.length;i++){
if(chkObjs[i].checked){
if(chk == i){
alert("radio值没有改变不能提交");
break;
}
}
}
}
</script>
</head>
<body>
<form action='' method='post' onsubmit='return check_radio()'>
<input type='radio' value='1' name='radio' checked='checked'>一;
<input type='radio' value='2' name='radio'>二;
<input type='radio' value='3' name='radio'>三;
<input type='radio' value='4' name='radio'>四;
<input type='radio' value='5' name='radio'>五;
<input type=submit value=sub >
</form>
</body>
</html>
=============================================
<asp:RadioButtonList ID="rblID" runat="server" RepeatColumns="7" RepeatLayout="Flow">
<asp:ListItem Value="1" Selected="True">选项一</asp:ListItem>
<asp:ListItem Value="2">选项二</asp:ListItem>
<asp:ListItem Value="3">选项三</asp:ListItem>
</asp:RadioButtonList>
注意各选项radio.ID的html生成规则分别为:rblID_0、rblID_1、rblID_2。即等同于:
<input id="rblID_0" type="radio" name="rblID" value="1" checked="checked" />
<input id="rblID_1" type="radio" name="rblID" value="2" />
<input id="rblID_2" type="radio" name="rblID" value="3" />
转载于:https://blog.51cto.com/taoyouth/1100059