onchange occurs when the selection, the checked state or the contents of an element have changed. In some cases, it only occurs when the element loses the focus. The onchange attribute can be used with: <input>, <select>, and <textarea>.
The oninput is useful if you want to detect when the contents of a textarea, input:text, input:password or input:search element have changed, because the onchange event on these elements fires when the element loses focus, not immediately after the modification.
The oninput event is supported in Mozilla Firefox , chrome, safari, Opera, Internet Explorer from version 9. For Internet Explorer before version 9 we may use the onpropertychange event. But the onpropertychange event is buggy in IE 9 and previous versions , as this does not gets fired when characters are deleted from a text field through the user interface.
Note: oninput event is also buggy in IE9 and it is not fired on deletion.
The oninput event is supported in Mozilla Firefox , chrome, safari, Opera, Internet Explorer from version 9.
Registering oninput and onchange events:
In HTML: <ELEMENT oninput="handler"> In JavaScript: object.oninput = handler; object.addEventListener ("input", handler, useCapture); object.attachEvent ("oninput", handler); | In HTML: <ELEMENT onchange="handler"> In JavaScript: object.onchange = handler; object.addEventListener ("change", handler, useCapture); object.attachEvent ("onchange", handler); |