Fires when a FORM is about to be submitted.
Syntax
Inline HTML | <FORM
onsubmit = "handler" ... >
| All platforms |
---|
Event property | FORM.onsubmit = handler | JScript only |
---|
FORM.onsubmit = GetRef("handler") | Visual Basic Scripting Edition (VBScript) 5.0 or later only |
Named script |
<SCRIPT FOR =
FORM EVENT = onsubmit>
| Internet Explorer only |
---|
Event Information
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. |
---|
ctrlKey |
Sets or retrieves the state of the CTRL key. |
---|
ctrlLeft |
Sets or retrieves the state of the left CTRL key.
|
---|
returnValue |
Sets or retrieves the return value from the event. |
---|
shiftKey |
Sets or retrieves the state of the SHIFT key. |
---|
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. |
---|
Remarks
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.
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>
Standards Information
This event is defined in
HTML 4.0 .
Applies To
See Also
ACTION, METHOD