Search code examples
javascriptdom-eventsonchange

onChange is called only when the element loses focus


I want that as you type in the textfield the div changes (I have the code for changing the div already). However the onchange event is only called once you are finished and click outside the textfield. I want it to be called as each letter is typed.

My code:

<input name="platetext" type="text" onchange="setValue(this)">

Solution

  • onChange is fired when the input looses focus I think. onKeyUp should do the trick for you.