开发者

Observe Form Submit

I use this to invoke a functio开发者_Python百科n 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜