views:

47

answers:

2

I use this to invoke a function when a form on the page is submitted:

$$("form").invoke("observe", "submit", submitForm);

I'm having a problem getting this to work in IE when a text field has focus and the enter key is pressed. Firefox submits the form in this case but not IE.

The form has one submit button:

<input type="submit" value="Submit"/>

Clicking the submit button works fine in both browsers using this method.

A: 

I think in Jquery what you might want is:

$(yourInputElem).keypress(function(e) {
    if(e.keyCode === 13){
         document.forms["yourFormHere"].submit();
     }
}

This then should submit the form for that input elem in IE.

stevebot
+1  A: 

I had the form inside of a <div style="display:none"> and for some reason just removing the display none did the trick. This was actually a JSP with other hidden forms using AJAX calls to control which form was displayed.

I should have posted more code than I did. Thanks to all who responded.

Tom