The onChange event gets triggered when the state of an element is changed. Many languages which work with a GUI support some form of a change-event. For example JavaScript and the JavsScript library jQuery (with the .change() function).
The onChange event gets triggered when the selection, the checked state or the contents of an element have changed.
JavaScript
In some cases the onchange event only occurs when the element loses the focus. In the event handler JavaScript code or function get be executed. This can for example be used to validate the data that has been entered by the user by calling a specified JavaScript function.
jQuery
jQuery uses the .change()
function which gets called onchange:
<input type="text" name="someinput">
$('input[name="someinput"]').change(function() { });
HTML
HTML supports the inline onchange
attribute. Most of the time JavaScript code or a JavaScript function gets executed from the onchange
attribute, e.g.:
<input type="text" name="someinput" onchange="dosomething()">
Please not that although this is supported most people will say that it is cleaner to remove all inline JavaScript from the HTML.