I have to limit the max selection in select 2 to one.
I familiar with the option maximumSelectionSize: 1
, but this option enable the user to enter text to the input/selcect-2 container, and also provide a message with "You can only select 1 item", and I don't need this message, and the user shouldn't be able to enter more text to the input after selected.
Asked
Active
Viewed 2,319 times
-1

Sarit Rotshild
- 391
- 3
- 5
- 21
-
So what have you tried? – D4V1D Sep 01 '15 at 09:56
-
@ D4V1D- I tried maximumSelectionSize: 1... – Sarit Rotshild Sep 01 '15 at 09:59
1 Answers
1
Select2's option is default to limit the selection by 1. You don't need to use maximumSelectionSize
option. Just call $(".select2").select2();
.
See example here

chungvh
- 46
- 1
- 4
-
@shess- I use version 3.5.2 , and if I don't use maximumSelectionSize I can select multiple selections. – Sarit Rotshild Sep 01 '15 at 11:17
-
@shess- I noticed that I put multiple:true by mistake. I removed it but then all my css is changed:( – Sarit Rotshild Sep 01 '15 at 12:03