HBCMS更多的中文手册参考:

onsubmit Event

DHTML文档教程

Fires when a form is about to be submitted.

dhtml语法

inline html<FORM onsubmit = "handler" ... > All platforms
Event propertyFORM.onsubmit = handlerJScript 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

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.

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.

DHTML代码范例

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>

是否符合公共标准

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

Applies To

FORM

更多语法参考

action, METHOD