faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

67 of 100 people (67%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Is there a way to capture the TAB key and prevent it from tabbing to another input field in a form or on the page? I need to know especially in IE4+.

Apr 4th, 2008 21:01
ha mo, Darton Williams, Colin Fraser, Garin Hess, developer.netscape.com


It can be done, but there's a catch: it won't work at all in Netscape 
4.x, because neither the onkeyDown nor the onkeyPress events return 
anything for the tab key in Netscape (not too sure about NS 6). 
However, it's very easy to do in IE:
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function noTab()
{
if(event.keyCode ==9)
	{
	return false;
	}
}
//--></SCRIPT>
</HEAD>
<BODY onKeyDown="return noTab()">
<FORM name="myForm">
<input type="text" name="text1">
<input type="text" name="text2">
<input type="submit">
</FORM>
</BODY>
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com