I have a input text and I apply it typeahead plugin for suggesting items, but when I press enter key on input text it submit form.
How can I prevent form submit using twitter bootstrap typeahead plugin?
You can target that specific input by adding an ID to it and simply removing the keydown event for enter like so:
JS
$(document).ready(function() {
$('form input').keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With