views:

31

answers:

2

Hi, i need to be able to able to detect when any character is entered into a textbox in Javascript, and clear another corresponding textbox. I have used the onfocus method for this but when tabbing between textboxes to get to submit, it removes the data and I don't want it to.

What methods are there I can use to trigger a JS event when a textbox is entered into?

+1  A: 

There are the following events

onkeydown

onkeyup

onkeypress

John Hartsock
onpaste, oncut, onmouseup (for drag and drop)...
Tim Down
Fantastic, thanks :)
Chris
A: 

if u use jquery

$("#myTextbox").keypress() $("#myTextbox").keyup() $("#myTextbox").keydown()

and if u want to findout which key was pressed, try

$("#myTextbox").keydown(funciton(e){ alert(e.which); });

if u not use e.which, u gonna have problem with cross browser

888