onsubmit Event
Fires when a form is about to be submitted.
Syntax
Inline HTML <FORM onsubmit = "handler" ... > All platforms Event property form.onsubmit = handler JScript (compatible with ECMA 262 language specification) only Named script <SCRIPT FOR = form EVENT = onsubmit> Internet Explorer only
Remarks
Bubbles No Cancels Yes 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.
altKey Retrieves the current state of the ALT key. ctrlKey Retrieves the state of the CTRL key. returnValue Sets or retrieves the return value from the event. shiftKey Retrieves the state of the SHIFT key. srcElement Retrieves the object that fired the event. type Retrieves 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 ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus.
See Also
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.