Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chosen.js - is it possible to limit the number of items selected?

I have a client that wants to give users the option to select up to 5 additional options from a list. I like the Chosen.js concept, but how can I limit the selection? I suppose one solution is to use the onChange to count the number selected and then disable the remainder, but is there a neater solution?

like image 658
Marc Wilson Avatar asked Jan 11 '13 03:01

Marc Wilson


1 Answers

Chosen provides a max_selected_options to allow you to do this:

$(".chzn-select").chosen({ max_selected_options: 5 });
like image 86
mccannf Avatar answered Oct 15 '22 21:10

mccannf