views:

3746

answers:

4

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?

+5  A: 

Last time i had that issue, i ended up using the onpropertychange event for IE instead. I even think i read somewhere on msdn, that it was the recommended way to get around it.

Edit: The "somewhere on msdn" is here

Tom Jelen
but it seems to fire everytime the user presses a key. am i doing something wrong here ?
Preets
No thats unfortunately how it works.But i just found this resource, which seems to address the issue in a nice way: http://jehiah.cz/archive/onchange-and-autocomplete
Tom Jelen
+3  A: 

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')"/>
Tim C
A: 

I just turn Autocomplete off for the text boxes I need to fire a text change event

'Turn off Auto complete 
'(it needs to fire the text change event)
 txtYourTextBox.Attributes.Add("AutoComplete", "off")

Just put that in the page load

Big Briyan
A: 

I just found that using jQuery 1.4 to set change event can solve this issue. It seems the easiest solution to this issue if you are already familiar with jQuery.

Darkthread