Reputation: 5225
Is there a way to fire an event every time I change the text on an <input type="text">
when the changes are not made pressing keys on the keyboard?
What I mean is I want to capture when somebody type in, right-click -> paste or drag a selected text on an input and not only when a key is pressed.
I've tried:
<input id="some-id" onchange="alert('fired')">
and
$('#some-id').on('change', ev_handler);
$('#some-id').change(ev_handler);
the only event that fires are the ones related to key press but they don't fire on pasting or dragging.
Upvotes: 1
Views: 3379
Reputation: 4684
oninput event could met your needs, but just note it's not well supported in older browsers. You can find more info on Dottoro.
If you need to cover all browsers and all use cases like you mentioned, there is really no better way then periodically check (for example every 500ms) your input value with JavaScript.
You can find discussion about that here on StackOverflow.
Upvotes: 3
Reputation: 1739
Try the onChange event, that should be issued everytime the input is changed, no matter how.
Upvotes: -2