how to make an checkboxlist select only two item?
<p>i have more than two checkboxlist. i want to limit users to select only 2 items for each checkboxlist.</p>

<pre><code>    &lt;asp:CheckBoxList ID="CheckBoxList1" runat="server"&gt;
        &lt;asp:ListItem Value="Item 1"&gt;Item 1&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 2"&gt;Item 2&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 3"&gt;Item 3&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 4"&gt;Item 4&lt;/asp:ListItem&gt;
    &lt;/asp:CheckBoxList&gt;

    &lt;asp:CheckBoxList ID="CheckBoxList2" runat="server"&gt;
        &lt;asp:ListItem Value="Item 1"&gt;Item 1&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 2"&gt;Item 2&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 3"&gt;Item 3&lt;/asp:ListItem&gt;
        &lt;asp:ListItem Value="Item 4"&gt;Item 4&lt;/asp:ListItem&gt;
    &lt;/asp:CheckBoxList&gt;
</code></pre>

<p>using javascript/jquery. Please help  </p>

<p><strong>SOLUTION:</strong></p>

<pre><code>&lt;script type="text/javascript"&gt;
    var i = 1;
            $(document).ready(function () {
            $('table[id^=CheckBoxList]').each(function (index) {
                var id = '#' + this.id;
                $(id).click(function (e) {
                  if ($(id).children().find('input[type="checkbox"]:checked').length &gt; 2) {
                        e.preventDefault();
                    }
                });
                i++;
            });
        });

&lt;/script&gt;
</code></pre>

<p>Thankz all :)</p>
