I've noticed that in different versions of Internet Explorer the onchange
event is not captured when the value of an input is altered by a js function, behavior that does not occur with other browsers such as Mozilla or Chrome.
Investigating a little I found that the correct operation of onchange
in IE is not guaranteed when the value is altered by js:
- onchange not fired on IE
onchange not fired when autocomplete is on
Example (test on IE):
function onchangeRequest(){
console.log('onchange fired');
}
function changeValue (input){
input.value += "hello"
}
<h4> focus lost doesnt invoke onchangeRequest() </h4>
<input id="valueInput" onkeyup="changeValue(this);" onchange="onchangeRequest();" />
<h4> focus lost invokes onchangeRequest() </h4>
<input id="valueInput" onchange="onchangeRequest();" />
I have not found a convincing explanation of the reasons why IE does not solve those situations correctly. Is this a "known bug" which we have to deal with? Is there any official reference where it is stated that IE does not guarantee the correct behavior of onchange event?