I have the following javascript code in the HEAD section...
And I have the following line in a form on the page:
The problem is that I don't know how to access the value of the keypress that triggered the event. Can anyone help me out here, JavaScript is not my forte...
omar khan
Ranch Hand
Joined: Feb 01, 2001
Posts: 183
posted
0
The return value of a JavaScript event handler is usually used to indicate the disposition on an event, namely to perform or nor a certain action. What are you trying to do? [ April 11, 2003: Message edited by: omar khan ]
Rajeshwari Natarajan
Ranch Hand
Joined: Mar 05, 2003
Posts: 67
posted
0
If u want to know which key was pressed, then u can try this... in the form
and in the script
regards<br />Rajeshwari. N
Sanjay Jadhav
Ranch Hand
Joined: Feb 21, 2002
Posts: 86
posted
0
hi As Rajeshwari siad it will work but not in netscape so may u need cross-browser javascript , as IE and Netscape handle the javascript event in different format.So u need the common javascript for both browser. sanjay_jk_2000@yahoo.com
Sanjay Jadhav<br />Sun Certified Programmer For Java 2 Platform
Thanks, all. That was very helpful - the information I was scrabbling for was the event.keyCode() method. Is there an equivalent I could use for IE and NN? Or a resource I could look at to find examples of cross-platform js event handling?
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
posted
0
if you looked at my link it shows the IE and NN Stuff, but look at this code <html> <head> <script> function checkTime(X) { Str=X.value; StrLen=Str.length; StrT=Str.slice(StrLen-1,StrLen); var StrRE1 = /^\d/; var StrRE2 = /^[0-2]/; var StrRE3 = /^:/;
else { Str=Str.slice(0,StrLen-1); X.value=Str; return true; } } </script> </head> <body> <form name="P"> <input type="text" name="B" onkeydown="checkTime(this)" onkeyup="checkTime(this)"> </form> </body> </html> There is one problem that I have with it, and I am going to try to fix, You can not edit it after it is changed! Eric