Limit the number of items the user can select in a ListBox with JQuery

This little script is able to grab all the listboxes on the page.

      $(document).ready(function() {
          $("select").change(function() {
             if ($(this).find('option:selected').length > 5) {
               this.options[this.selectedIndex].selected = false;
             }; }); }); 

pretty sleek huh?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.