当前位置:首页 > 程序&理念 >

JS判断多个单选框必须选择一个

时间:2008-05-21 18:35:31浏览:13927 本站原创


<form name=\"myform\" action=\"bluecode.asp\" method=\"\" onsubmit=\"return check()\">
<input type=\"radio\" name=\"bluecode\" value=\"1\">
<input type=\"radio\" name=\"bluecode\" value=\"2\">
<input type=\"radio\" name=\"bluecode\" value=\"3\">
<input type=\"submit\" value=\"Submit\">
</form>
<script language=\"JavaScript\">
function check(){
    var flag=0
    for(i=0;i<myform.bluecode.length;i++){
    if(myform.bluecode[i].checked==true){
        flag=1
        break
    }
    }
    if(!flag){
        alert(\"对不起, 你一个都没有选\")
        return false
    }
}
</script>
1

上一篇:5.12汶川特大地震,网站快速彩色变黑白
下一篇:在看什么呢

发表评论

昵称:  验证码:

关于博主

博主

博主:BlueCode

职业:web程序

简介:2002年开始一直从事Web制作,网站运营,会PHP+MYSQL ASP+MSSQL,微信开发