Hitting "enter" does not post form in IE8

Also watch out for this fun fun bug:

I've learned the hard way that if your form is display:none at page load, even if you show it later with Javascript, IE8 still won't submit on enter. However, if it's not hidden at page load, and you set it to display:none after, like onDOMReady, then it works! WTF

More details and workaround here: http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter


Simulate a click

Here's how I do it in jQuery.

// Recreating normal browser behavior in Javascript. Thank you, Microsoft.
jQuery.fn.handle_enter_keypress = function() {
  if ($.browser.msie){
    $(this).find('input').keypress(function(e){
      // If the key pressed was enter
      if (e.which == '13') {
        $(this).closest('form')
        .find('button[type=submit],input[type=submit]')
        .filter(':first').click();
      }
    });
  }
}

$('form').handle_enter_keypress();

Here is a link in Microsoft on it which might shed some light for you.

Taking a quick read of the link it might actually be considered a bug submitting the form by the Enter Key, which I presume would of been fixed by Microsoft for IE8.

IE anomaly when using the enter key to submit a form

Edit:

This has now been removed but another link covering it again (bottom of page) which defined it and explaining the bug in IE Blog on December 18th 2008.