13 Oct 2011

limit the no of items user can check in ckeckboxlist using jquery

<script type="text/javascript" language="javascript">
        //Count the Total Selection in CheckBoxList - BusinessType
        $('#<%= cblBusinessType.ClientID %>').find('input:checkbox').click(function()
        {
             var totCount=0;

             jQuery('#<%= cblBusinessType.ClientID %>').find("input:checkbox").each(function() {

             if (jQuery(this).attr("checked"))
             {
               totCount++;
             }

           });
           if(totCount > 3)
           {
               alert("Select up to 3 Business Types only...");
               return false;
           }

           return true;

        });
</script>

No comments:

Post a Comment