Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

require 3 characters to start search in multiple select #552

Closed
chrishough opened this Issue Mar 30, 2012 · 2 comments

Comments

Projects
None yet
2 participants

is there a way to prevent the search until the user has entered 3 characters?

mr9 commented Jun 4, 2012

Somewhere around line 800, after
searchText = this.search_field.val() === this.default_text ? "" : $('div').text($.trim(this.search_field.val())).html();
in
Chosen.prototype.winnow_results
I added:
if(!searchText && this.is_multiple) return this.results_hide();
to require at least 1 character to be entered, but for 3 you'd do:
if(searchText.length < 3 && this.is_multiple) return this.results_hide();

If you want the same behavior for single selects remove the && this.is_multiple. I'm using the single selects as a sort of dropdown list so I don't want to require typing. I wouldn't say this is fully tested, but it seems to work.

@mr9 thank you for posting this, really helped .

@chrishough chrishough closed this Jun 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment