onchange event

Fires when the contents of the object or selection have changed.

 

Syntax

HTML Attribute <element onchange = "handler(event)">
Event Property object.onchange = handler;
attachEvent Method object.attachEvent("onchange", handler)
addEventListener Method object.addEventListener("change", handler, useCapture)

 

Event information

Synchronous No
Bubbles No
Cancelable Yes

 

Event handler parameters

Standards information

Remarks

This event is fired when the contents are committed and not while the value is changing. For example, on a text box, this event is not fired while the user is typing, but rather when the user commits the change by leaving the text box that has focus. In addition, this event is executed before the code specified by HTMLInputTextElementEvents::onblur when the control is also losing the focus.

The HTMLInputTextElementEvents::onchange event does not fire when the selected option of the select object is changed programmatically.

Changed text selection is committed.

To invoke this event, do one of the following:

  • Choose a different option in a select object using mouse or keyboard navigation.
  • Alter text in the text area and then navigate out of the object.

The pEvtObj parameter is required for the following interfaces:

See also

HTMLInputTextElementEvents::onkeypress