Search code examples
javascriptjqueryonchange

Can javascript tell the difference between user input and dynamic update?


I need to be able to use javascript/jquery to update a field. But I need to be able to check whether the input was updated manually by the user or if the input was dynamically updated using a document.getElementById().value.

onChange() method seems to execute no matter if the user modified the control, or if I dynamically updated the control.

Any help? Is there something similar to onChange() that only executes when a user manually types/edits a control?


Solution

  • You can manually edit the .value of an input element, and as long as the element was not focussed by the user, an onChange event is not fired by most browsers.