var b=0;
var a=document.getElementsByTagName("input");
for(var i=0;i<a.length;i++){
   if(a[i].type=="checkbox"){
        if(a[i].checked){
            b=b+1;
        }
   }
}
if(b==0){
   alert("no one checked");
}

解决方案 »

  1.   

    name="m_business_type1"
    name="m_business_type2"
    name="m_business_type3"
    name="m_business_type4"

    你的只是"input"
      

  2.   

    我这里有个笨方法,但实用易懂!不知对你是否有用!
    if m_business_type1="" and m_business_type2="" and m_business_type3="" and m_business_type4="" and m_business_type5="" then
    Response.Write"<script>alert('错误:康复服务内容不能为空!');history.back();</script>"
    Response.end
    end if
      

  3.   

    var b=0;
    var a=document.getElementsByTagName("input");
    for(var i=0;i<a.length;i++){
       if(a[i].type=="checkbox"){
            if(a[i].name.length > 15){
                if(a[i].name.substr(0,15) =="m_business_type"){
                    if(a[i].checked){
                        b=b+1;
                    }
                }
            }
       }
    }
    if(b==0){
       alert("no one checked");
    }