Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 470
Preets Avatar asked Dec 05 '08 08:12

Preets


People also ask

Does autofill trigger Onchange?

Some fields in a form will look for a change before the form can be submitted. When a field is Autofilled by Kiosk Pro, the field doesn't notice a change, so an "onChange event" will need to be triggered. This screening happens post factum meaning that the page will load before it is blocked.

Why Onchange is not working in JS?

onchange is not fired when the value of an input is changed. It is only changed when the input's value is changed and then the input is blurred. What you'll need to do is capture the keypress event when fired in the given input. Then you'll test the value of the input against the value before it was keypressed.

What triggers Onchange event?

The onchange event occurs when the value of an element has been changed. For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed.

How does Onchange work in Javascript?

The onchange attribute fires the moment when the value of the element is changed. Tip: This event is similar to the oninput event. The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus.


1 Answers

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.

like image 70
Tom Jelen Avatar answered Sep 22 '22 12:09

Tom Jelen