判断一组Radio选择 是否被选择了 [自编javascript函数]
网上找了找,有选择了的。。但是没有符合我的要求的。。所以自己写了一个。。吼吼。。
 <html>
<html>
 <head>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
 <title>判断一组Radio选择 是否被选择了</title>
<title>判断一组Radio选择 是否被选择了</title>
 </head>
</head>

 <body>
<body>
 <script type="text/javascript">
<script type="text/javascript">
 function check()
function check()
 {
{
 if(!IsSeleRadio("b"))
    if(!IsSeleRadio("b"))
 {
    {
 alert("b还没有选择");
        alert("b还没有选择");
 }
    } 
 }
}

 //彭彭编写 是否选择了Radio
//彭彭编写 是否选择了Radio
 function IsSeleRadio(bname)
function IsSeleRadio(bname)
 {
{
 
    
 var bn = document.getElementsByName(bname);
    var bn = document.getElementsByName(bname);
 var k = 0;//全部都没有 回来和bn.length对比用的
    var k = 0;//全部都没有 回来和bn.length对比用的
 for(i=0;i<bn.length;i++)
    for(i=0;i<bn.length;i++)
 {
    {
 if(!bn[i].checked)
        if(!bn[i].checked)
 {
        {
 k++;
            k++;
 }
        }
 }
    }
 if(k == bn.length)
    if(k == bn.length)
 {
    {
 return false;
        return false;
 }
    }
 else
    else
 {
    {
 return true;
        return true;
 }
    }
 }
}
 </script>
</script>
 <form id="form1" name="form1" method="post" action="">
<form id="form1" name="form1" method="post" action="">
 <p>
  <p>
 <input type="radio" name="b" value="radiobutton" />
    <input type="radio" name="b" value="radiobutton" /> 
 000
  000
 <input type="radio" name="b" value="radiobutton" />
  <input type="radio" name="b" value="radiobutton" />
 111
  111
 <input type="radio" name="b" value="radiobutton" />
  <input type="radio" name="b" value="radiobutton" /> 
 222</p>
222</p>
 <p>
  <p>
 <input type="radio" name="a" value="radiobutton" />
    <input type="radio" name="a" value="radiobutton" /> 
 333
    333
 <input type="radio" name="a" value="radiobutton" />
    <input type="radio" name="a" value="radiobutton" />
 444
  444
 <input type="radio" name="a" value="radiobutton" />
  <input type="radio" name="a" value="radiobutton" />
 555</p>
  555</p>
 <p>
  <p>
 <input type="submit" onclick="check();return false;" name="Submit" value="提交" />
    <input type="submit" onclick="check();return false;" name="Submit" value="提交" />
 </p>
  </p>
 </form>
</form>
 </body>
</body>
 </html>
</html>
 
 
 <html>
<html> <head>
<head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>判断一组Radio选择 是否被选择了</title>
<title>判断一组Radio选择 是否被选择了</title> </head>
</head>
 <body>
<body> <script type="text/javascript">
<script type="text/javascript"> function check()
function check() {
{ if(!IsSeleRadio("b"))
    if(!IsSeleRadio("b")) {
    { alert("b还没有选择");
        alert("b还没有选择"); }
    }  }
}
 //彭彭编写 是否选择了Radio
//彭彭编写 是否选择了Radio function IsSeleRadio(bname)
function IsSeleRadio(bname) {
{ 
     var bn = document.getElementsByName(bname);
    var bn = document.getElementsByName(bname); var k = 0;//全部都没有 回来和bn.length对比用的
    var k = 0;//全部都没有 回来和bn.length对比用的 for(i=0;i<bn.length;i++)
    for(i=0;i<bn.length;i++) {
    { if(!bn[i].checked)
        if(!bn[i].checked) {
        { k++;
            k++; }
        } }
    } if(k == bn.length)
    if(k == bn.length) {
    { return false;
        return false; }
    } else
    else {
    { return true;
        return true; }
    } }
} </script>
</script> <form id="form1" name="form1" method="post" action="">
<form id="form1" name="form1" method="post" action=""> <p>
  <p> <input type="radio" name="b" value="radiobutton" />
    <input type="radio" name="b" value="radiobutton" />  000
  000 <input type="radio" name="b" value="radiobutton" />
  <input type="radio" name="b" value="radiobutton" /> 111
  111 <input type="radio" name="b" value="radiobutton" />
  <input type="radio" name="b" value="radiobutton" />  222</p>
222</p> <p>
  <p> <input type="radio" name="a" value="radiobutton" />
    <input type="radio" name="a" value="radiobutton" />  333
    333 <input type="radio" name="a" value="radiobutton" />
    <input type="radio" name="a" value="radiobutton" /> 444
  444 <input type="radio" name="a" value="radiobutton" />
  <input type="radio" name="a" value="radiobutton" /> 555</p>
  555</p> <p>
  <p> <input type="submit" onclick="check();return false;" name="Submit" value="提交" />
    <input type="submit" onclick="check();return false;" name="Submit" value="提交" /> </p>
  </p> </form>
</form> </body>
</body> </html>
</html>
    ---------------------------------------------
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.gitee.io/navigator/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.gitee.io/navigator/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)




 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号