Category Covered

Multiple selection dropdown list limit controll

 I have a multiple selection dropdown list. I want to controll the limit using jquery so i just use the following jquery and its work fine for me.

 

$(document).ready(function() {
    $('#ItemOptions option').click(function() 
    {
        var items = $(this).parent().val();
        if (items.length > 3) {
           alert("You can only select 3 values at a time");
           $(this).removeAttr("selected");
        }
    });
});