diff --git a/README.md b/README.md
index 9832340..097b1da 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,7 @@ $('table').filterTable(); //if this code appears after your tables; otherwise, i
| `inputName` | string | filter-table | Name attribute of the filter input field |
| `inputType` | string | search | Tag name of the filter input itself |
| `label` | string | Filter: | Text to precede the filter input |
+| `minChars` | integer | 1 | Filter is only applied to a table when at least this many characters are entered |
| `minRows` | integer | 8 | Only show the filter on tables with this number of rows or more |
| `placeholder` | string | search this table | HTML5 placeholder text for the filter input |
| `quickList` | array | [] | List of clickable phrases to quick fill the search |
@@ -83,6 +84,10 @@ Other than jQuery, the plugin will take advantage of Brian Grinstead's [bindWith
## Change Log
+### 1.5.4
+
+- Added a `minChars` option, thanks to [Darius Kazemi](https://github.com/dariusk), which specifies the minimum number of characters a user must enter into a filter before filtering occurs. Default is 1, meaning the moment the user begins to type, filtering will occur.
+
### 1.5.3
- **There is a potentially significant change in functionality in this version.** While the documentation offered the `inputSelector` option, within the code it was implemented as `filterSelector`. This has been corrected to match the documentation. Note that if you were previously using the `filterSelector` option to overcome this issue, you will need to change it to `inputSelector` to use the feature with this version.
diff --git a/jquery.filtertable.js b/jquery.filtertable.js
index 6422d6f..2785b0f 100644
--- a/jquery.filtertable.js
+++ b/jquery.filtertable.js
@@ -6,7 +6,7 @@
*
* Utilizes bindWithDelay() if available. https://github.com/bgrins/bindWithDelay
*
- * @version v1.5.3
+ * @version v1.5.4
* @author Sunny Walker, swalker@hawaii.edu
*/
(function($) {
@@ -34,6 +34,7 @@
inputName: '', // name of filter input field
inputType: 'search', // tag name of the filter input tag
label: 'Filter:', // text to precede the filter input tag
+ minChars: 1, // don't start filtering until this many characters are entered
minRows: 8, // don't show the filter on tables with less than this number of rows
placeholder: 'search this table', // HTML5 placeholder text for the filter field
quickList: [], // list of phrases to quick fill the search
@@ -49,7 +50,7 @@
var doFiltering = function(table, q) { // handle the actual table filtering
var tbody=table.find('tbody'); // cache the tbody element
- if (q==='') { // if the filtering query is blank
+ if (q==='' || q.length < settings.minChars) { // if the filtering query is blank or the number of chars entered is less than minChars
tbody.find('tr').show().addClass(settings.visibleClass); // show all rows
tbody.find('td').removeClass(settings.highlightClass); // remove the row highlight from all cells
if (settings.hideTFootOnFilter) { // show footer if the setting was specified
diff --git a/jquery.filtertable.min.js b/jquery.filtertable.min.js
index 8487edc..d080fd4 100644
--- a/jquery.filtertable.min.js
+++ b/jquery.filtertable.min.js
@@ -6,7 +6,7 @@
*
* Utilizes bindWithDelay() if available. https://github.com/bgrins/bindWithDelay
*
- * @version v1.5.3
+ * @version v1.5.4
* @author Sunny Walker, swalker@hawaii.edu
*/
-!function(e){var t=e.fn.jquery.split("."),i=parseFloat(t[0]),a=parseFloat(t[1]);e.expr[":"].filterTableFind=2>i&&8>a?function(t,i,a){return e(t).text().toUpperCase().indexOf(a[3].toUpperCase())>=0}:jQuery.expr.createPseudo(function(t){return function(i){return e(i).text().toUpperCase().indexOf(t.toUpperCase())>=0}}),e.fn.filterTable=function(t){var i={autofocus:!1,callback:null,containerClass:"filter-table",containerTag:"p",hideTFootOnFilter:!1,highlightClass:"alt",inputSelector:null,inputName:"",inputType:"search",label:"Filter:",minRows:8,placeholder:"search this table",quickList:[],quickListClass:"quick",quickListGroupTag:"",quickListTag:"a",visibleClass:"visible"},a=function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")},l=e.extend({},i,t),n=function(e,t){var i=e.find("tbody");""===t?(i.find("tr").show().addClass(l.visibleClass),i.find("td").removeClass(l.highlightClass),l.hideTFootOnFilter&&e.find("tfoot").show()):(i.find("tr").hide().removeClass(l.visibleClass),l.hideTFootOnFilter&&e.find("tfoot").hide(),i.find("td").removeClass(l.highlightClass).filter(':filterTableFind("'+t.replace(/(['"])/g,"\\$1")+'")').addClass(l.highlightClass).closest("tr").show().addClass(l.visibleClass)),l.callback&&l.callback(t,e)};return this.each(function(){var t=e(this),i=t.find("tbody"),s=null,r=null,o=null,c=!0;"TABLE"===t[0].nodeName&&i.length>0&&(0===l.minRows||l.minRows>0&&i.find("tr").length>l.minRows)&&!t.prev().hasClass(l.containerClass)&&(l.inputSelector&&1===e(l.inputSelector).length?(o=e(l.inputSelector),s=o.parent(),c=!1):(s=e("<"+l.containerTag+" />"),""!==l.containerClass&&s.addClass(l.containerClass),s.prepend(l.label+" "),o=e('')),l.autofocus&&o.attr("autofocus",!0),e.fn.bindWithDelay?o.bindWithDelay("keyup",function(){n(t,e(this).val())},200):o.bind("keyup",function(){n(t,e(this).val())}),o.bind("click search",function(){n(t,e(this).val())}),c&&s.append(o),l.quickList.length>0&&(r=l.quickListGroupTag?e("<"+l.quickListGroupTag+" />"):s,e.each(l.quickList,function(t,i){var n=e("<"+l.quickListTag+' class="'+l.quickListClass+'" />');n.text(a(i)),"A"===n[0].nodeName&&n.attr("href","#"),n.bind("click",function(e){e.preventDefault(),o.val(i).focus().trigger("click")}),r.append(n)}),r!==s&&s.append(r)),c&&t.before(s))})}}(jQuery);
\ No newline at end of file
+!function(e){var t=e.fn.jquery.split("."),i=parseFloat(t[0]),a=parseFloat(t[1]);e.expr[":"].filterTableFind=2>i&&8>a?function(t,i,a){return e(t).text().toUpperCase().indexOf(a[3].toUpperCase())>=0}:jQuery.expr.createPseudo(function(t){return function(i){return e(i).text().toUpperCase().indexOf(t.toUpperCase())>=0}}),e.fn.filterTable=function(t){var i={autofocus:!1,callback:null,containerClass:"filter-table",containerTag:"p",hideTFootOnFilter:!1,highlightClass:"alt",inputSelector:null,inputName:"",inputType:"search",label:"Filter:",minChars:1,minRows:8,placeholder:"search this table",quickList:[],quickListClass:"quick",quickListGroupTag:"",quickListTag:"a",visibleClass:"visible"},a=function(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")},l=e.extend({},i,t),n=function(e,t){var i=e.find("tbody");""===t||t.length0&&(0===l.minRows||l.minRows>0&&i.find("tr").length>l.minRows)&&!t.prev().hasClass(l.containerClass)&&(l.inputSelector&&1===e(l.inputSelector).length?(o=e(l.inputSelector),s=o.parent(),c=!1):(s=e("<"+l.containerTag+" />"),""!==l.containerClass&&s.addClass(l.containerClass),s.prepend(l.label+" "),o=e('')),l.autofocus&&o.attr("autofocus",!0),e.fn.bindWithDelay?o.bindWithDelay("keyup",function(){n(t,e(this).val())},200):o.bind("keyup",function(){n(t,e(this).val())}),o.bind("click search",function(){n(t,e(this).val())}),c&&s.append(o),l.quickList.length>0&&(r=l.quickListGroupTag?e("<"+l.quickListGroupTag+" />"):s,e.each(l.quickList,function(t,i){var n=e("<"+l.quickListTag+' class="'+l.quickListClass+'" />');n.text(a(i)),"A"===n[0].nodeName&&n.attr("href","#"),n.bind("click",function(e){e.preventDefault(),o.val(i).focus().trigger("click")}),r.append(n)}),r!==s&&s.append(r)),c&&t.before(s))})}}(jQuery);