In my experience, input type="text"
onchange
event usually occurs only after you leave (blur
) the control.
Is there a way to force browser to trigger onchange
every time textfield
content changes? If not, what is the most elegant way to track this “manually”?
Using onkey*
events is not reliable, since you can right-click the field and choose Paste, and this will change the field without any keyboard input.
Is setTimeout
the only way?.. Ugly :-)
Below code works fine for me with Jquery 1.8.3
HTML :
<input type="text" id="myId" />
Javascript/JQuery:
onkeyup
happens after you type for example I presst
when I lift the finger the action happens but onkeydown
the action happens before I digit the charactert
Hope this is helpful for someone.
So
onkeyup
is better for when you want to send what you just typed now.