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)?
See Question&Answers more detail:osIn 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)?
See Question&Answers more detail:osIt 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.