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)?
Asked
Active
Viewed 8,050 times
10
-
Can you show us some code? What event do you want to be attached to it? Not having IE10, I'm not sure, but does that element have any markup associated with it, or is it part of the native browser chrome? – nickcoxdotme Feb 05 '13 at 05:05
-
@nickcoxdotme It's native to IE 10. You can download it for free, you know: http://www.modern.ie/virtualization-tools – Nick Feb 05 '13 at 05:08
-
doesn't have any markup. it comes built in with text boxes in IE10. Code: just display some text. – ABC Feb 05 '13 at 05:08
-
@ABC Have you tried `onchange`? – Teemu Feb 05 '13 at 06:54
-
@Teemu, no, let me try it. – ABC Feb 05 '13 at 07:43
2 Answers
13
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.

Teemu
- 22,918
- 7
- 53
- 106
0