JavaScript » eventhandler » onReset

onReset = myJavaScriptCode

Event handler for Form

The onReset event handler is used to execute specified JavaScript code whenever the user resets a form by cicking a Reset button. It uses the following properties of the Event object:
type - indicates the type of event
target - indicates the target object to which the event was sent.


<FORM NAME="form1" onReset="alert('Reset to Book of the Month.')">
<P>Select a Book:<BR>
<INPUT TYPE="text" NAME="MonthBook" VALUE="The Joys of JavaScript" SIZE="25"></P>
<P><INPUT TYPE="reset" VALUE="Editor's Choice" NAME="reset1"> </P></FORM>

This example for a possible on-line book club creates a text field for the names of books with the default being the Editor's Book of the Month. The user can at any time reset it to the default which will cause the onReset event handler to display a message saying that the text will be reset to the Book of the Month.

See Also: