Is it possible to bind javascript (jQuery is best) event to "change" form input value somehow?
I know about .change()
method, but it does not trigger until you (the cursor) leave(s) the input field. I have also considered using .keyup()
method but it reacts also on arrow keys and so on.
I need just trigger an action every time the text in the input changes, even if it's only one letter change.
I had to use this kind of code for a scanner that pasted stuff into the field
Not tested...
There is a simple solution, which is the HTML5
input
event. It's supported in current versions of all major browsers for<input type="text">
elements and there's a simple workaround for IE < 9. See the following answers for more details:Example (except IE < 9: see links above for workaround):
I don't think there's a 'simple' solution. You'll probably need to use both the events onKeyUp and onChange so that you also catch when changes are made with the mouse. Every time your code is called you can store the value you've 'seen' on this.seenValue attached right to the field. This should make a little easier.