Skip to content

Instantly share code, notes, and snippets.

@byronwade
Created September 11, 2013 04:18
Show Gist options
  • Save byronwade/6519303 to your computer and use it in GitHub Desktop.
Save byronwade/6519303 to your computer and use it in GitHub Desktop.
<input class="" type="text" value="Search" id="search">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
(function() {
$("#search").autocomplete({});
// Overrides the default autocomplete filter function to search only from the beginning of the string
$.ui.autocomplete.filter = function (array, term) {
var matcher = new RegExp("\\b" + $.ui.autocomplete.escapeRegex(term), "i");
return $.grep(array, function (value) {
return matcher.test(value.label || value.value || value);
});
};
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment