Custom Fields
Support Meta Box Geolocation How to disable submit when selecting an address?

  • Creator
  • #16422
    Resolved brandonjp

    Currently if a user selects an address using the keyboard (using arrow keys and then hitting the return/enter key on an address) it submits the entire form & causes the page to page to refresh (if Post) or adds the new term (if Taxonomy)

    Is there a Meta Box way of disabling form submission on return when selecting an address with the keyboard?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
  • #16429

    I’m basically having the same problem. When using the [enter] key I would expect to have the option selected but the complete page form is actually submitted.

    Tried setting a return false on the input field that is the parent of autocomplete pop-down, but apparently that is not the element where we can check on the keyup event for that pop-down.


    On my sites, I’m currently using this 👇 chain which disables autocomplete on the address fields (in Chrome) and prevents the return key:

    jQuery('form#post input[id^=address][type=text]').attr('autocomplete', 'new-password').keypress(function(e) {
      if (e.which == 13) return false;

    A few other options for this…

    This 👇 disables submission anytime the Enter/Return key is pressed inside any form element (including Google Maps, but also on any other element):

    jQuery(' form#post').keypress(function(e) {
      if (e.which == 13) return false;

    Here 👆 I’m targeting only the pages for my custom post type called CUSTOMPOST (so change that to your post type) or else just use jQuery('form#post').... to attach this to all edit post screens.

    And for completeness… there is also Google Maps’ prescribed way of adding event listeners: 👇

    google.maps.event.addDomListener(jQuery('#idOfTextInput')[0], 'keydown', function(e) {
      if (e.keyCode === 13) return false;

    Since we’re in WordPress, I’m still using jQuery here 👆 you could easily write it with plain JS if needed. But since I’m still using jQuery here, I don’t see the reason for using the Google Maps method.

    Anh Tran

    Just fixed this issue in the latest version of Meta Box Geolocation.


    That’s great 👍

    Will this be available via the Composer repo soon? Tried updating but there were no available yet.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.


Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.

grid gear info copy caret-up caret-down trash