| ||||||||||||||||||||||||||||||||||||||||||||||||||||
onchange EventFires when the contents of the object or selection have changed. Syntax
Remarks
A change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT type=text, SELECT, TEXTAREA element. 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 onblur when the control is also losing the focus. On the SELECT object, this event does not fire programmatically when the selected attribute is changed from one OPTION to another. Event Object PropertiesWhile event handlers in the Document Object Model do not receive parameters directly, the handler can query the event object for data.
ExampleThe example below shows how the onchange event works on the SELECT object. The following example shows use of the onchange event to trigger the function checkNum that checks for a range of values. If the value of the INPUT element is not within the valid range, the focus and select methods are used to set focus back to and highlight the INPUT. Otherwise, it calls the function thanks. <input name="num"
onchange="if (!checkNum(this.value, 1, 10))
{this.focus();this.select();} else {thanks()}"
value="0">
Applies ToHTMLAREA, INPUT type=text, SELECT, TEXTAREA See Also |
| |||||||||||||||||||||||||||||||||||||||||||||||||||
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme