Q:

Preventing form from submition on autosuggest

I have the following form:
<form action="/web/projects/add" id="EventAddForm" method="post" accept-charset="utf-8">
    <div style="display:none;"><input type="hidden" name="_method" value="POST"/></div> 
    <div class="input text">
        <label for="AddressSearch">Search address</label>
        <input name="adress_search" type="text" id="AddressSearch"/>
    </div>
    <div class="input text required">
        <label for="EventAddress">Address</label>
        <input name="data[Event][address]" type="text" id="EventAddress"/>
    </div>
    <div class="input text required">
        <label for="EventPostNr">Post nr</label>
        <input name="data[Event][post_nr]" type="text" id="EventPostNr"/>
    </div>
    <div class="input text required">
        <label for="EventCity">City</label>
        <input name="data[Event][city]" type="text" id="EventCity"/>
    </div>
    <div class="submit">
        <input  type="submit" value="Save"/>
    </div>
</form>

The previously mentioned fields are used for choosing autosuggested addresses by google maps and I omit that code for better readability, but the problem appears when the autosuggest dropdown appears. If a users navigates to one of the suggestion by keyboard and presses enter, the whole form is submitted. I have the following function to prevent the form from submition on mouse click:
jQuery('#EventAddForm').submit(function( event ) {
  if ( $("#AddressSearch").is(":focus") ||
    $("#EventPostNr").is(":focus") ||
    $("#EventCity").is(":focus"))
    event.preventDefault();
 });

But what I want to do is to prevent the form on the enter click as well.
I lack some knowledge in jQuery and just cannot get it running, so any help or guidance is much appreciated.

A:

It's not a good idea to specify all the fields in case they change. 
Instead use a more generic selector.
jQuery('#EventAddForm').submit(function( event ) {
    if ($(this).find('input:text:focus').length) event.preventDefault();
});

http://jsfiddle.net/KpXD3/

