Skip to content

Commit

Permalink
Excludes non alphanumeric characters from minChars check
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal Feroz committed Jul 27, 2023
1 parent 1c00c94 commit 5aa5a69
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>jQuery-Autocomplete</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devbridge-autocomplete",
"version": "1.4.11",
"version": "1.4.13",
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
"authors": [
"Tomas Kirda"
Expand Down
2 changes: 1 addition & 1 deletion devbridge-autocomplete.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ajax",
"autocomplete"
],
"version": "1.4.11",
"version": "1.4.13",
"author": {
"name": "Tomas Kirda",
"url": "https://github.com/tkirda"
Expand Down
10 changes: 5 additions & 5 deletions dist/jquery.autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Ajax Autocomplete for jQuery, version 1.4.11
* Ajax Autocomplete for jQuery, version 1.4.13
* (c) 2017 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
Expand Down Expand Up @@ -226,7 +226,7 @@

that.fixPosition();

if (that.el.val().trim().length >= that.options.minChars) {
if (that.el.val().replace(/[^A-Z0-9]/ig, '').length >= that.options.minChars) {
that.onValueChange();
}
},
Expand Down Expand Up @@ -493,7 +493,7 @@
return;
}

if (query.trim().length < options.minChars) {
if (query.replace(/[^A-Z0-9]/ig, '').length < options.minChars) {
that.hide();
} else {
that.getSuggestions(query);
Expand Down Expand Up @@ -776,7 +776,7 @@
var that = this,
onHintCallback = that.options.onHint,
hintValue = '';

if (suggestion) {
hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
}
Expand All @@ -786,7 +786,7 @@
if ($.isFunction(onHintCallback)) {
onHintCallback.call(that.element, hintValue);
}
}
}
},

verifySuggestionsFormat: function (suggestions) {
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.autocomplete.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devbridge-autocomplete",
"version": "1.4.11",
"version": "1.4.13",
"description": "Autocomplete provides suggestions while you type into the text field.",
"homepage": "https://github.com/devbridge/jQuery-Autocomplete",
"author": "Tomas Kirda (https://twitter.com/tkirda)",
Expand Down
8 changes: 4 additions & 4 deletions src/jquery.autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@

that.fixPosition();

if (that.el.val().trim().length >= that.options.minChars) {
if (that.el.val().replace(/[^A-Z0-9]/ig, '').length >= that.options.minChars) {
that.onValueChange();
}
},
Expand Down Expand Up @@ -493,7 +493,7 @@
return;
}

if (query.trim().length < options.minChars) {
if (query.replace(/[^A-Z0-9]/ig, '').length < options.minChars) {
that.hide();
} else {
that.getSuggestions(query);
Expand Down Expand Up @@ -776,7 +776,7 @@
var that = this,
onHintCallback = that.options.onHint,
hintValue = '';

if (suggestion) {
hintValue = that.currentValue + suggestion.value.substr(that.currentValue.length);
}
Expand All @@ -786,7 +786,7 @@
if ($.isFunction(onHintCallback)) {
onHintCallback.call(that.element, hintValue);
}
}
}
},

verifySuggestionsFormat: function (suggestions) {
Expand Down

0 comments on commit 5aa5a69

Please sign in to comment.