Monday, October 13, 2008

IE beeps on enter in an input

Problem:
I have an input box where the onKeyDown event will check if the key pressed was enter, and submit the form on enter. This works fine, but in IE 7 the browser beeps when you press enter, and submits the form.

Solution:
This happens because 'enter' is not valid within the context of an input box, according to IE. Thus, pressing it will cause the beep. What you need to do to remove the beep, is to return false from the function which does the submit. It looks something like this:

<input onkeydown="return postOnEnter(event)"/>



obviously, i am calling some custom functions in the snippet above, but the location of the return statements, and their values is all that matters.

6 comments:

  1. Thanks, this helped me.

    ReplyDelete
  2. Thank you very much! This helped me out after weeks of searching for an answer to this nonsensical problem.

    ReplyDelete
  3. Thanks man , this saved me time.Thank you very muck.I really hate IE.
    Thanks.

    ReplyDelete
  4. Thanks! this was just what I was looking for!

    ReplyDelete
  5. Wow, I spent hours trying to figure this out, thank you sooooo much for the answer. :)

    ReplyDelete
  6. Thank you! This is exactly what I needed to fix this problem. Stupid IE...

    ReplyDelete