onreset

HTML (DHTML)

onreset Event

Internet Development Index

Fires when the user resets a form.

Syntax

Inline HTML<FORM onreset = "handler" ... > All platforms
Event propertyFORM.onreset = handlerJScript only
FORM.onreset = GetRef("handler")Visual Basic Scripting Edition (VBScript) 5.0 or later only
Named script <SCRIPT FOR = FORM EVENT = onreset> Internet Explorer only

Event Information

BubblesNo
CancelsYes
To invoke
Default action Executes associated code.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query an event object for data.

Available Properties

altKey Sets or retrieves a value that indicates the state of the ALT key.
altLeft Sets or retrieves a value that indicates the state of the left ALT key.
ctrlLeft Sets or retrieves the state of the left CTRL key.
returnValue Sets or retrieves the return value from the event.
shiftLeft Retrieves the state of the left SHIFT key.
srcElement Sets or retrieves the object that fired the event.
type Sets or retrieves the event name from the event object.

Example

This example demonstrates how to use the onreset event for a form object. Reset the form by clicking the first or second button. The only difference between the two buttons is that the second button invokes the reset method of the form object and the first button is of input type=reset. When either button is pressed the form is reset, resulting in the onreset event call on the form object. The onreset event calls an event handler which in turn adds the text Resetting form. to the text area below.

<HTML>
<HEAD>
<SCRIPT>
function doReset(){
oTextArea1.innerText += "Resetting form.  ";
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="form1" onreset="doReset();"
<B>Form</B><BR>
style="border:2px solid #cccccc; background:#EEEEEE; padding:10px; ">
<b>Enter some text:</b>
<INPUT type="text" name="oText1" value=""><BR><BR>
<INPUT TYPE="reset" value="Input type=reset"/>
<BUTTON onclick="form.reset();">form.reset()</BUTTON>
</FORM>
<B>Form status</B><BR>
<SPAN id="oTextArea1" ></SPAN>
<BR><BR>
<BUTTON onclick="location.reload(true);">Refresh Page</BUTTON>
</BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

Standards Information

This event is defined in HTML 4.0 Non-Microsoft link.

Applies To

FORM

See Also

reset