title: Submit form data both on clicking enter and hitting the submit button from a Bootstrap modal window
body: <p>Here's my form that's in my modal window:</p>
  
  <p>I have no close button and I have disabled the window from closing on pressing esc. I want to be able to submit the form data on pressing submit or on pressing the enter key. </p>
  
  <pre><code>&lt;div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false"&gt;
      &lt;div class="modal-header"&gt;
          &lt;h3 id="myModalLabel"&gt;Enter your Credentials&lt;/h3&gt;
      &lt;/div&gt;
      &lt;div class="modal-body"&gt;
          &lt;form id="login-form" class="form-horizontal" accept-charset="UTF-8"  data-remote="true""&gt;
              &lt;div class="control-group"&gt;
                  &lt;label class="control-label" for="inputEmail"&gt;Email&lt;/label&gt;
                  &lt;div class="controls"&gt;
                      &lt;input type="email" id="email" name="email" value=""  placeholder="Email"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="control-group"&gt;
                  &lt;label class="control-label" for="inputPassword"&gt;Password&lt;/label&gt;
                  &lt;div class="controls"&gt;
                      &lt;input type="password" id="passwd" name="passwd" value="" placeholder="Password"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="control-group"&gt;
                  &lt;div class="controls"&gt;
                      &lt;label class="checkbox"&gt;
                          &lt;input type="checkbox"&gt; Remember me
                      &lt;/label&gt;
                      &lt;input type="submit"  id="login" value="Login"class="btn btn-primary" /&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;          
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's the script I'm using:</p>
  
  <pre><code>$(document).ready(function(){
      $('#myModal').modal('show');
  });
  
  function submitLogin() {
      $.ajax({
          url:"login_mysql.php",
          type:'POST',
          dataType:"json",
          data: $("#login-form").serialize()
      }).done(function(data){
          //do something
      });
  }
  
  $('#passwd').keypress(function(e) {
      if (e.which == '13') {
          submitLogin();
      }
  });
  
  $('#login').click(function(){
      submitLogin();
  });
  </code></pre>
  
  <p>On pressing enter after keying in my password or clicking on the submit button the same page reloads and the ajax script does not run. Could someone tell me if my script is clashing with the default settings of my modal window? </p>