Why does the javascript onchange event not fire if autocomplete is on?

I have a textbox with an onchange event. Why does this event not fire when the user uses the autocomplete feature to populate the textbox?

I am working with Internet Explorer. Is there a standard and relatively simple solution to workaround this problem, without me having to disable the autocomplete feature?


Solution 1:

Last time I had that issue, I ended up using the onpropertychange event for Internet Explorer instead. I read about that here on MSDN: it is the recommended way to get around it.

Solution 2:

I've encountered this annoying feature before and my solution at the time was to use the onfocus event to record the current value of the text box, and then use the onblur event to check whether the current value now matches the value saved during onfocus. For example

<input type="text" name="txtTest" value="" onfocus="this.originalvalue=this.value" onblur="if (this.value != this.originalvalue) alert('Test has changed')"/>