Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript input onchange not working

why this doesn´t work:

inputButton.addEventListener('onchange', jsFunction, false);

I change the inputbox and it doesn´t call jsFunction.

like image 351
FernandoSBS Avatar asked May 22 '10 21:05

FernandoSBS


People also ask

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.

Does Onchange work for input text?

That's why onchange is used with form controls, like input, select, checkbox, radio buttons, etc. The Javascript listens for user input and fires this event whenever a value gets updated.

How does Onchange event 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

Try change instead of onchange

inputButton.addEventListener('change', jsFunction, false);
like image 180
Soufiane Hassou Avatar answered Oct 10 '22 16:10

Soufiane Hassou