You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
Limit minimum input items to 1 (Opposite of maxOptions) #1228
Make sure I'm reporting something precise that needs to be fixed
Give my issue a descriptive and concise title
Create a minimal working example on JsFiddle or Codepen
(or gave a link to a demo on the Selectize docs)
Indicate precise steps to reproduce in numbers and the result,
like below
I made an app that use selectize for user input. Desktop only, and it's on http://typography.philipyoungg.com
In short, is there any API to limit selectize value to 1 (no empty input)?
or if there wasn't, can I hack this somehow?
I've tried to add keydown listener and use jQuery e.stopImmediatePropagation(), but it's not working—because the listener instantiated afterwards.
closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.
@risadams This should be reopened unless it is a duplicate. Request seems to be pretty clear and relevant, unless there is an alternative way to achieve this.
Reopening. I do think this has merit, but can see issues in execution.
a) What happens when there are no options in the list?
b) what should the initial state be?
c) Should this prevent removing the final item? should default to the first option?
d) Is this a feature that controls behavior, or only validation on a form submit.
Side note. we would totally welcome a pull request
Very valid quesstions. The next time I find a usecase where I need this feature, it would be easy for me to answer. Hopefully others who want this can chime in.
Hi, I indeed found this issue by an initial google search. To add some thoughts, I think it would be great if minOptions n could also assume non-1 positive integer values (i.e. I want n=3 minimum options to be selected at a given time)
a) What happens when there are no options in the list?
Given my above comment, if the number of options in the list are < n, I think an error would be acceptable.
b) what should the initial state be?
lst.splice(n)
c) Should this prevent removing the final item? should default to the first option?
Yes, I think users should be prevented from removing the last n items
d) Is this a feature that controls behavior, or only validation on a form submit.
Controls behavior.
I'm sure there are many other use cases that do not match my own, but I wanted to share what I was hoping for when I googled for this feature.
Activity
fabiangehring commentedon Feb 8, 2018
I just came accross this when looking for a minItems options. Is there a chance a minItems options will be implemented?
Joozty commentedon Apr 25, 2018
I think this would be great feature :)
risadams commentedon Nov 30, 2020
closing stale issues older than one year.
If this issue was closed in error please message the maintainers.
All issues must include a proper title, description, and examples.
daattali commentedon Feb 26, 2021
I do think this would be very useful. Seems to be a commonly googled question.
byapparov commentedon Jul 7, 2021
@risadams This should be reopened unless it is a duplicate. Request seems to be pretty clear and relevant, unless there is an alternative way to achieve this.
daattali commentedon Jul 7, 2021
I opened a new issue #1642 since this is closed
risadams commentedon Jul 8, 2021
Reopening. I do think this has merit, but can see issues in execution.
a) What happens when there are no options in the list?
b) what should the initial state be?
c) Should this prevent removing the final item? should default to the first option?
d) Is this a feature that controls behavior, or only validation on a form submit.
Side note. we would totally welcome a pull request
daattali commentedon Jul 8, 2021
Very valid quesstions. The next time I find a usecase where I need this feature, it would be easy for me to answer. Hopefully others who want this can chime in.
allisonvuong commentedon Apr 15, 2022
Hi, I indeed found this issue by an initial google search. To add some thoughts, I think it would be great if minOptions
ncould also assume non-1 positive integer values (i.e. I wantn=3minimum options to be selected at a given time)Given my above comment, if the
number of options in the list are < n, I think an error would be acceptable.lst.splice(n)Yes, I think users should be prevented from removing the last
nitemsControls behavior.
I'm sure there are many other use cases that do not match my own, but I wanted to share what I was hoping for when I googled for this feature.
Thank you and hi @daattali!