0

I am trying to make form submit with TAB button.

It is working on FF, IE8, but on IE9 i cannot stop default action.

I found the answer here: How do I convert Enter to Tab (with focus change) in IE9? It worked in IE8

But i cannot implement it.

Could somebody explain what "Fix" for ie9 i should add my script to work.

Thank you

function checkcode(e) {
    var keycode;
    if(!e)
        e = window.event;
    if(e.keyCode)
       keycode = e.keyCode;
    else
       keycode = e.charCode; 
    if(keycode == 9 || keycode == 13) {
        e.preventDefault();            //Problem is here
        alert(keycode);
        return false;
    } else return true;
}
Community
  • 1
  • 1
Simba
  • 41
  • 7
  • Anybody? This is useful for everyone :) – Simba Jul 26 '11 at 13:18
  • I tried using: e.cancelBubble = true; e.stopPropagation(); if (e.preventDefault) { e.preventDefault() } else { e.returnValue = false alert('preventing'); } but that does not work. I am thinking TAB button is processed before event. Any help would be appreciated. – Simba Jul 29 '11 at 18:18

1 Answers1

1

Problem was that in IE onkeypress does not return keycodes for ctrl, shift or tab, onkeydown done the trick.

Simba
  • 41
  • 7