Click to return to the DHTML, HTML     
onstop Event     onunload Event     DHTML Events    
Web Workshop  |  DHTML, HTML & CSS

onsubmit Event


Fires when a form is about to be submitted.

Syntax

Inline HTML<FORM onsubmit = "handler" ... >All platforms
Event propertyform.onsubmit = handlerJScript (compatible with ECMA 262 language specification) only
Named script<SCRIPT FOR = form EVENT = onsubmit>Internet Explorer only

Remarks

BubblesNo
CancelsYes
To invoke Submit a form using the INPUT TYPE=submit, INPUT TYPE=image, or BUTTON TYPE=submit object.
Default action Causes a form to be sent to whatever location is stipulated in the ACTION attribute of the form object.

You can override this event by returning false in the event handler. Use this capability to validate data on the client side to prevent invalid data from being submitted to the server. If the event handler is called by the onsubmit attribute of the form object, the code must explicitly request the return value using the return function, and the event handler must provide an explicit return value for each possible code path in the event handler function.

The submit method does not invoke the onsubmit event handler.

Event Object Properties

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

Event Object Properties

altKeyRetrieves the current state of the ALT key.
ctrlKeyRetrieves the state of the CTRL key.
returnValueSets or retrieves the return value from the event.
shiftKeyRetrieves the state of the SHIFT key.
srcElementRetrieves the object that fired the event.
typeRetrieves the event name from the event object.

Example

This example shows how to use onsubmit on a form to request the return value using the return function.

<BODY>
<FORM NAME="oDoSubmit" onsubmit="return(myOnSubmitEventHandler());">
</FORM>
</BODY>

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:

FORM

See Also

ACTION, METHOD



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.