Need help submitting form using .submit()

Need help submitting form using .submit()

Hey Guys,

 I am trying to simply submit a form when clicking the enter key. For some reason the form does not do any submission. It will do other things like if I do an alert("Hello World") when clicking on enter but not submitting the form.

Can someone help me figure out why this isn't working

below is the code

Thanks



  1. <form id="form" action="radio.html" method="post">
  2. <input id="1" class="rad" type="radio" name="rad">
  3. <div class="text_1"> Some text 1 </div>
  4.     <input id="submit" type="submit" value="submit"/>
  5. </form>

  1. $(document).on("keypress",function(e){
  2.     var key = e.which;
  3.     if(key == 13){
  4.         $("#form").submit(function() { return true;});
  5.         //$("#form").trigger("submit");
  6.     }
  7. });