@@ -1248,6 +1248,15 @@ the specific language governing permissions and limitations under the Apache Lic
12481248 render ( "<li class='select2-searching'>" + opts . formatSearching ( ) + "</li>" ) ;
12491249 }
12501250
1251+ if ( opts . maximumInputLength && search . val ( ) . length > opts . maximumInputLength ) {
1252+ if ( checkFormatter ( opts . formatInputTooLong , "formatInputTooLong" ) ) {
1253+ render ( "<li class='select2-no-results'>" + opts . formatInputTooLong ( search . val ( ) , opts . maximumInputLength ) + "</li>" ) ;
1254+ } else {
1255+ render ( "" ) ;
1256+ }
1257+ return ;
1258+ }
1259+
12511260 // give the tokenizer a chance to pre-process the input
12521261 input = this . tokenize ( ) ;
12531262 if ( input != undefined && input != null ) {
@@ -2405,11 +2414,13 @@ the specific language governing permissions and limitations under the Apache Lic
24052414 formatResultCssClass : function ( data ) { return undefined ; } ,
24062415 formatNoMatches : function ( ) { return "No matches found" ; } ,
24072416 formatInputTooShort : function ( input , min ) { var n = min - input . length ; return "Please enter " + n + " more character" + ( n == 1 ? "" : "s" ) ; } ,
2417+ formatInputTooLong : function ( input , max ) { var n = input . length - max ; return "Please enter " + n + " less character" + ( n == 1 ? "" : "s" ) ; } ,
24082418 formatSelectionTooBig : function ( limit ) { return "You can only select " + limit + " item" + ( limit == 1 ? "" : "s" ) ; } ,
24092419 formatLoadMore : function ( pageNumber ) { return "Loading more results..." ; } ,
24102420 formatSearching : function ( ) { return "Searching..." ; } ,
24112421 minimumResultsForSearch : 0 ,
24122422 minimumInputLength : 0 ,
2423+ maximumInputLength : null ,
24132424 maximumSelectionSize : 0 ,
24142425 id : function ( e ) { return e . id ; } ,
24152426 matcher : function ( term , text ) {
0 commit comments