In this HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
</head>
<body>
Enter some number here:
<input type="number" min="0"
oninput="console.log(' on input ');
this.value = Math.abs(this.value);"
onchange="console.log(' on change');"/>
</body>
</html>
The input has 2 event handlers
- input
- change
However onchange is not called.
Note, the oninput handler changes the value of the input. If I remove
this.value = Math.abs(this.value);
both events are fired.
This behaviour seen in Microsoft Edge 44.17763.1.0 (Microsoft EdgeHTML 18.17763)
This does not happen in Chrome nor in Firefox.
Questions
- What am I doing wrong?
- Is this from an inherited large code base with many input's all with an oninput and an onchange. The onchange is not called. What is the most efficient way to fix this? (Disclaimer:I'm no HTML / javascript expert.)