参见 http://topic.csdn.net/u/20081230/11/66796f91-378b-4ee4-be44-5d92125778b6.html

解决方案 »

  1.   

    你是用什么?用jquery吗?用的话 我写个给你,普通的js 我也写个给你 ==
      

  2.   

    lsc1202001 那个贴刚看了。。不适合我这个。。少于两个也会提示的。
      

  3.   

    先谢谢 liuhua19841201 
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
      <SCRIPT LANGUAGE="JavaScript"> 
    <!-- 
    function checkSure(obj) 

    var arr=document.getElementsByName('a');
    var numin=0;
    for(var i=0;i<arr.length;i++){
        if(arr[i].checked)
    {
      numin++;
    }
    }
    if(numin>3){
      obj.checked=false;
      alert("最多3个");}
    }
    //--> 
    </SCRIPT>  </HEAD> <BODY> 
      <input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)">
        <input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)"><input type="checkbox" name="a"/ onclick="checkSure(this)">
     </BODY>
    </HTML>
      

  5.   

    需要jquery写的告诉我 qq316184674 看到这个帮我删掉,不要把我的联系给别人
      

  6.   

    不管是checked 还是selected 都是数组 你只要判断被选中的才长度就可以了 
      

  7.   

    学习 #########
    ---------------------------------
    http://www.officego.cn
      

  8.   

    <html><head><title>dddd</title>
    <script language="javascript">
    function CkForm()
    {
    var oC=document.form1.sItem;
    var t=0;
    if(oC){
    for(var i=0;i<oC.length;i++)
    {
    if(oC(i).checked) t++
    }
           }if(t>4 || t<2)
    {
     alert("产品比较至少选择2个,最多选择4个产品!");
    return false;
     }else{
     return true;
     }
    }</script></head>
    <body><SCRIPT LANGUAGE="javascript"> </script> <form name="form1" ID="Form1" action="nextPage.htm" onsubmit="return CkForm(); " > 
    请最多选择7个项目: 
    <p> 
    <input type="checkbox" value="CRC" name="sItem">a <br/>
    <input type="checkbox" value="Northsnow" name="sItem" ID="Checkbox1"> b <br/>
    <input type="checkbox" value="CSDN" name="sItem" ID="Checkbox2"> c <br/>
    <input type="checkbox" value="a" name="sItem" ID="Checkbox3"> 飞 <br/>
    <input type="checkbox" value="b" name="sItem" ID="Checkbox4"> 雪 <br/>
    <input type="checkbox" value="c" name="sItem" ID="Checkbox5"> 连 <br/>
    <input type="checkbox" value="d" name="sItem" ID="Checkbox6"> 天 <br/>
    <input type="checkbox" value="e" name="sItem" ID="Checkbox7"> 射 <br/>
    <input type="checkbox" value="f" name="sItem" ID="Checkbox8"> 白 <br/>
    <input type="checkbox" value="g" name="sItem" ID="Checkbox9"> 鹿 <br/>
    <input type="submit" name="ss" value="OK" >
    </form> 
    </body>
    </html>
    实现了呵呵