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.
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):
$("#your_id").on("input", function() {
alert("Change to " + this.value);
});