marco-pm / zencart_instantsearch

Instant Search plugin for Zen Cart
GNU General Public License v3.0
2 stars 4 forks source link

Minimum search term? #12

Closed torvista closed 2 years ago

torvista commented 2 years ago

I don't think a search should be initiated for at least three characters (for unnecessary server requests). What do you think about an Admin option for setting a minimum search term length, before the ajax is sent?

torvista commented 2 years ago

I had decided to prevent this earlier in the process, in instant_search.js

let searchWord = typedSearchWord.replace(/^\s+/, "").replace(/  +/g, ' ');
        if (searchWord === "" || $(this).val().length < 3) {//steve 3 chars minimum
            resultsContainer.hide();

But its not so easy to get the db constant value at this point.

torvista commented 2 years ago

Just realised you already pull in a constant in jscript\jscript_instant_search.php, so this could do the same.