asp.net.ph

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


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



Contents
HTML Elements
HTML Element Attributes
CSS Properties
DOM Events Reference

Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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