(function () {
var el = document.getElementById("MyInput"),
ignore = false;
el.oninput = function (e) {
// ignore the events that we don't need to capture
if (ignore) {
ignore = false;
return true;
}
// Your code here
}
// IIRC, you need the following line for the `ondrop` event to fire
el.ondragover = function () { return false; }
// Ignore paste, drop and keypress operations
el.onpaste = el.ondrop = el.onkeypress = setIgnore;
function setIgnore (e) {
ignore = true;
}
})();