This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the web-development category.
Last Updated: 2024-12-03
I added a Google Maps address autocomplete field to the form for posting to a
job board. If I'd already typed a few keys, pressing enter selected the
suggestion from Google. Unfortunately it also submitted the form prematurely if
I had not typed any keys yet. The solution was to add a preventDefault()
at
the appropriate place.