I built a listener to prevent form submission using a special ocasion.
I use google maps autocomplete api and basically I donβt want to submit the form when users press the enter button and the Recommended Results window is displayed. When users click, enter to select a value from the drop-down list and not to submit the form.
I created a listener that catches the event correctly, but I donβt know how to prevent form submission.
$('body').live('keydown', function(e) { if($(".pac-container").is(":visible") && event.keyCode == 13) { e.preventDefault();
I tried with e.preventDefault (); but he still represents the form. Form ID: updateAccountForm
How can I prevent this?
EDIT: I should note that it seems that listening to keystrokes directly to the search input is contrary to the Google API, which deprives the autocomplete function. So $('input#search') keydown / keypress is not possible
source share