1

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 the .php file listed in the attribute of the form f1_1.

Thanks

Community
  • 1
  • 1
  • is there no way to bring the .php reference into the javascrit itself? I don't think so. Ajax can not handle file uploads last I heard. –  Oct 04 '11 at 18:16
  • function bind_fu(event) { if(event.keyCode==13) { return false; } } –  Oct 04 '11 at 18:23

2 Answers2

0

From google and assuming no javascript library like Jquery:

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

Daren Schwenke
  • 5,428
  • 3
  • 29
  • 34
0

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;
    }
  }