By axel4891
Wednesday, 6. February 2008, 22:51:09

how to prevent default keypress event
Hi
I've got a problem. For example I have 3 inputs on the page. How can I prevent (turn off) navigation by 'tab' key between these inputs? I've tried many things:
1. e.preventDefault();
2. e.stopPropagation();
3. return true;
and even such construction:
document.onkeypress = function(){
var e = window.event;
e.preventDefault();
e.stopPropagation();
}
but nothing of it turns off tab navigation. How can I solve it?
Thanks for advance.
By einzelgaenger83a
Friday, 4. April 2008, 15:36:52

No Solutions? I have the same problem and I'm very interested to know how to solve it
By moginspace
Wednesday, 9. April 2008, 15:09:22

Well not sure why you'd want to take away the browser's basic functionality? Don't you want users to be able to jump into an input field?
Anyway... the only way I know to get an input out of the tab cycle is to change the <input> tag to disabled like this:
<input type="text" disabled>
If your inputs are styled with css then they will look the same even though one is disabled.
Like this:
<input tabindex="1" type="text" style="background-color:#fff;">
<input tabindex="2" type="text" style="background-color:#fff;">
<input tabindex="3" type="text" disabled style="background-color:#fff;">