In IE10 a small X icon appears in the textbox to clear the input text. How can an event be attached to that action (=clicking on that X and clearing the input)?
It seems there's not an exact event for this (onchange is not suitable). However, you can use oninput and check, if the value of the input is empty:
document.getElementById('input_ID').addEventListener('input', function () {
if (this.value === '') {
alert('No value');
}
}, false);
This event is triggered also, if user clears the input with BACKSPACE or DELETE, or cuts the content to the clipboard. oninput works at least in Chrome, FF, IE10 and Opera.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With