开发者

disabling functionality of the enter key for a file upload [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Disabling enter key for form

How do I disable the enter key on a file upload input box. I submit this form progmatically in javascript. I don't want the user to submit it by pressing the enter key (this is what happens when the user presses the enter key).

The programatic submit is with in an ajax call like this.

document.f1_1.submit();

It calls t开发者_如何学编程he .php file listed in the attribute of the form f1_1.

Thanks


From google and assuming no javascript library like Jquery:

http://www.bloggingdeveloper.com/post/Disable-Form-Submit-on-Enter-Key-Press.aspx


This is easier than the other SO and google posts I've seen. Works on IE 9 at a minimum.

Just bind this method to the input box:

function bind_fu(event)
  {
  if(event.keyCode==13)
    {
    return false;
    }
  }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜