aspxtreme

onsubmit Event

DHTML Events


Fires when a FORM is about to be submitted.

Syntax


Inline HTML <FORM onsubmit = "handler" ... > All platforms
Event property form.onsubmit = handler ECMA-262 Language Specification
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.

A submit event occurs when a form is submitted. This event only applies to the FORM element.

This event can be overridden by returning false in the event handler. This capability is useful for the developer who wants 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.

Note that submitting a form thru script using the submit method does not invoke the onsubmit event handler.

Event Object Properties

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

Event Object Properties

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

The example demonstrates how to request the return value using the return function when using onsubmit on a form.

<form onsubmit = "return validateForm(this)">
   ... form control definitions here ...
</form>

 Show me 

Applies To

FORM

See Also

action, method, Data Entry Validation Routines



Books and more ...

Contents
HTML Elements / DOM Objects
HTML Element Attributes
CSS Attributes
DOM Object Properties
DOM-compliant Events Reference
DOM Methods Reference
DOM Collections Reference
 


Suggested Reading



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme