andynic
06-21-2009, 01:10 PM
Hi,
I'm a newbie to javascript.
I want to disable the backspace key unless the cursor is in an <INPUT> field.
More specifically:
Given the tags on a page:
<body onkeydown='checkKeyRedefine();' … > (where … signifies other attributes)
and
<INPUT name="userAddress" …>
I would like to have a javascript function something like this:
function checkKeyRedefine()
{
var tagName = ?????? is there for example, a DOM function to put here ????
if (window.event.keyCode == 8)
{
if ( tagName != "userAddress" )
{
alert ("key disabled in this context");
}
}
}
Thanks very much for your help.
andynic
I'm a newbie to javascript.
I want to disable the backspace key unless the cursor is in an <INPUT> field.
More specifically:
Given the tags on a page:
<body onkeydown='checkKeyRedefine();' … > (where … signifies other attributes)
and
<INPUT name="userAddress" …>
I would like to have a javascript function something like this:
function checkKeyRedefine()
{
var tagName = ?????? is there for example, a DOM function to put here ????
if (window.event.keyCode == 8)
{
if ( tagName != "userAddress" )
{
alert ("key disabled in this context");
}
}
}
Thanks very much for your help.
andynic