trouble with onkeydown

G

George Hester

This element is the only disabled=false element on the form:

<HEAD>
....
<SCRIPT type="text/javascript">
<!-- Begin
function ValidateKey(e);
e = event || window.event;
var key;
var skey;
if (document.layers){
key = e.which;
skey = e.which;
} else {
key = e.keyCode;
skey = e.keyCode;
}
alert(key);
// ...
return (true);
}
// End -->
</SCRIPT>
....
</HEAD>
<BODY onload="JavaScript:document.forms['frm1'].elements['1'].focus(); ...."
....
<FORM id="frm1" ...>
<INPUT id="1" type="text" onkeydown="JavaScript:ValidateKey();" ..../>
....

When the document loads a message comes up which says 0. This seems wrong to me since no key was pressed. I understand why though. But what makes it worse is that if the message box is OK'd and the user types ANY character key such as m; p; t;... but not either of the ctrl keys or alt (those kind) on the keyboard, a message box comes up that says 0.

And then the issue is compounded because if the user OK's that message box and types another character, those that I described above then no message box; which is what I expect in the whole procedure here. The first one I can deal with but my "what makes it worse" is really uncalled for and I cannot figure out how to get the first key entered to not return 0. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top