Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onChange and onBlur cannot see the event.keyCode

Status
Not open for further replies.

cawthor

Programmer
May 31, 2001
89
US
I am trying to execute a function when a text box focus is lost via the TAB key. I added a condition to the 'onBlur' event of the text box to check the keycode, but it always returns 0. Same for 'onChange'. Is there a way for these events to recognise that the TAB key was pressed?
 
yeah thats what I feared. But if I have an 'onkeypress' AND an 'onblur' event on the same text box, then pressing TAB executes the onblur event (skipping the keypress event where I can check for the keycode). I require the onblur event in case the user selects a different form element with the mouse. Any ideas??
 
I think you need to give a bit more detail as to why you need to specifically detect for the Tab key, as there may well be other ways to do whatever it is you want to do.

By default, Tab will cause focus to move to the next field, so usually checking for the onblur event is enough.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top