An Onsubmit event can silently kill an onchange event if it is called at the same time. I guess the race condition in the js engine. Tested in Chrome, FF3, FF6 and IE9.
To play, you need to change the contents of the input and press the submit button. Do not make any extra clicks between changing the input and pressing the submit button.
<div id="somediv">
<div>one</div>
<div>two</div>
</div>
<form method="POST" id="someform">
<input type="text" name="input1" id="someinput" value="change me" />
<input type="submit" />
</form>
<script type="text/javascript">
document.getElementById('someinput').onchange = function() {
document.getElementById('somediv').getElementsByTagName('div')[1].style.display = 'none';
}
document.getElementById('someform').onsubmit = function() {
alert('This event is not called');
}
</script>
Expected Behavior: onchange event than onsubmit.
If we use the button instead of sending and triggering events one by one, everything works as expected.
If there are no operations in the onchange event (no delay), it works as expected.
If onchange changes the color of the div (doesn't display) - sometimes (3/10) works, as expected, lol.
js guru, please explain what the hell is going on?