Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

require 3 characters to start search in multiple select #552

Closed
chrishough opened this Issue · 2 comments

2 participants

@chrishough

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

@mr9
mr9 commented

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.

@chrishough

@mr9 thank you for posting this, really helped .

@chrishough chrishough closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.