Some puzzling javascript triggering an onchange handler


I have something puzzling with an input field at the page:

If typing the word Millésime in the first question input field, then the answer is correct.

But, let’s say your computer keyboard does not offer the é letter, you use the é letter by clicking on it in the “Mini clavier”.

The problem then, is that the onchange handler is triggered. I would like to add a letter in the input field but not trigger the onchange handler.

Any one sees a solution ?



onchange is triggered whenever you blur the input field, which you do when you click your other field. Simplest to remove the onchange event, though you could give it a timeout and cancel it when the other field is focused.

I’m not sure if my explanation was clear enough for you to understand it. I click in the input field, I then type in a few letters, like Mill, and then I click on the displayed é letter above. It should add this é letter in the input field so as to have Millé, and it should not do any blur nor change, because I wish to finish typing in my word, so as to have in the input field the word Millésime, and then I can click to the next field, triggering the onchange and see the ajax correction.


I now understand what is going on:

The onchange event will be triggered before the onclick handler is performed :
1°) user is writing in the input field
2°) user clicks on the mini keyboard
3°) input field lose focus
4°) input field’s onchange event is triggered
5°) mini keyboard has focus
6°) mini keyboard’s onclick handler is performed

Which shows me you clearly understood the problem from the start.

Following up on your two suggestions, if I remove the onchange event handler, then how would I handle changes if the on screen keyboard is not used ?