0

how do I avoid a server request in typeahead.js if certain regex matches? I dont't want to start a suggestion if numbers are typed in but letters should start the ajax request.

Is this possible in typeahead.js or bloodhound?

I still have version 0.10.5 as an update would affect in too many places.

best regards Eike

Eike
  • 1
  • 1

1 Answers1

0

I found a solution by myself: Just return false in beforeSend.

engine = new Bloodhound({
   ajax: {
       url: "example.com",
       beforeSend: function() {
           return null === $(<selector>).typeahead("val").match(/regexIdontWant/);
       }
   }
});
Eike
  • 1
  • 1