Limiting the number of selections

Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected. The select below is declared with the multiple attribute with maximumSelectionLength in the select2 options.

{% highlight js linenos %} $(".js-example-basic-multiple-limit").select2({ maximumSelectionLength: 2 }); {% endhighlight %}