[Contents] [Previous] [Next] [Index]

onChange

Executes JavaScript code when a change event occurs; that is, when a Select, Text, or Textarea field loses focus and its value has been modified.

Event handler for

FileUpload, Select, Text, Textarea

Implemented in

Navigator 2.0 event handler for Select, Text, and Textarea
Navigator 3.0: added as event handler of FileUpload

Syntax

onChange="handlerText"

Parameters

handlerText
JavaScript code or a call to a JavaScript function.

Description

Use onChange to validate data after it is modified by a user.

Event properties used

type
Indicates the type of event.

target
Indicates the object to which the event was originally sent.

Examples

In the following example, userName is a text field. When a user changes the text and leaves the field, the onChange event handler calls the checkValue function to confirm that userName has a legal value.

<INPUT TYPE="text" VALUE="" NAME="userName" 
   onChange="checkValue(this.value)">

See also

onBlur, onFocus

For general information on event handlers, see "General Information about Events".

For information about the event object, see event.


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 16:34:02


Copyright � 1997 Netscape Communications Corporation