An effective way is to use a combination of onkeydown and onpaste , which will work in IE, Firefox, Chrome and Safari. Opera is weird here because it does not support onpaste , so you may need to return to onchange for Opera or use the DOMAttrModified mutation DOMAttrModified , see the example below.
Internet Explorer also supports onpropertychange , which will be triggered every time an element property changes, including value . I read that DOMAttrModified supported by Opera and Safari (not sure about Firefox), so you can use this in conjunction with IE onpropertychange (untested):
if ("implementation" in document && document.implementation.hasFeature('MutationEvents','2.0')) myInput.addEventListener("DOMAttrModified", valueChanged, false); else if ("onpropertychange" in myInput) myInput.onpropertychange = valueChanged; function valueChanged (evt) { var attr; evt = evt || window.event; attr = evt.attrName || evt.propertyName; if (attr == "value") validate(); }
source share