判断一组Radio选择 是否被选择了 [自编javascript函数]

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

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


//彭彭编写 是否选择了Radio
function IsSeleRadio(bname)
{
    
    
var bn = document.getElementsByName(bname);
    
var k = 0;//全部都没有 回来和bn.length对比用的
    for(i=0;i<bn.length;i++)
    
{
        
if(!bn[i].checked)
        
{
            k
++;
        }

    }

    
if(k == bn.length)
    
{
        
return false;
    }

    
else
    
{
        
return true;
    }

}

</script>
<form id="form1" name="form1" method="post" action="">
  
<p>
    
<input type="radio" name="b" value="radiobutton" /> 
  000
  
<input type="radio" name="b" value="radiobutton" />
  111
  
<input type="radio" name="b" value="radiobutton" /> 
222
</p>
  
<p>
    
<input type="radio" name="a" value="radiobutton" /> 
    333
    
<input type="radio" name="a" value="radiobutton" />
  444
  
<input type="radio" name="a" value="radiobutton" />
  555
</p>
  
<p>
    
<input type="submit" onclick="check();return false;" name="Submit" value="提交" />
  
</p>
</form>
</body>
</html>
---------------------------------------------
生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
↑面的话,越看越不痛快,应该这么说:

生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
原文地址:https://www.cnblogs.com/pengchenggang/p/951013.html