Showing posts with label webdev. Show all posts
Showing posts with label webdev. Show all posts

18.10.06

onchange before onsubmit: no dice for IE

I'm sure this has been blogged endlessly and documented in msdn, but I just ran across this: On an HTML form, an input's onchange event won't get called when the input is changed and ENTER is hit. Apparently IE6 doesn't think it needs to.

This bug doesn't happen in Firefox, nor it happens if you're trying to use onblur. Try it:
<form onsubmit="alert('submit')">
<input onchange="alert('change')" onblur="alert('blur')" />
</form>
Update: I apologize for not posting a workaround. You can add an event which forces the input to blur (without having to explicitly define which input):
<form onsubmit="window.focus()">