Name
Input.onchange: event handler invoked when a form elementâs value changes â DOM Level 2 Events
Synopsis
Function onchange
Description
The onchange
property of an
Input object specifies an event-handler function that is invoked
when the user changes the value displayed by a form element. Such a
change may be an edit to the text displayed in input elements of
type âtextâ, âpasswordâ, and âfileâ, or the selection or deselection
of a toggle button of type âradioâ or âcheckboxâ. (Radio and
checkbox elements always trigger the onclick
handler and may also trigger the
onchange
handler.) Note that this
event handler is invoked only when the user makes such a change; it
is not invoked if a JavaScript program changes the value displayed
by an element.
Also note that the onchange
handler is not invoked every time the user enters or deletes a
character in a text-entry form element. onchange
is not intended for that type of
character-by-character event handling; instead, onchange
is invoked when the userâs edit
is complete. The browser assumes that the edit is complete when
keyboard focus is moved from the current element to some other
elementâfor example, when the user clicks on the next element in the
form. See HTMLElement.onkeypress
for character-by-character event notification.
The onchange
event handler
is not used by input elements of type âbuttonâ, âhiddenâ, âimageâ,
âresetâ, and âsubmitâ. Elements of those types use the onclick
handler instead. ...
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.