[Contents] [Previous] [Next] [Index]

onSubmit

Executes JavaScript code when a submit event occurs; that is, when a user submits a form.

Event handler for

Form

Implemented in

Navigator 2.0

Syntax

onSubmit="handlerText"

Parameters

handlerText
JavaScript code or a call to a JavaScript function.

Security

Navigator 4.0: Submitting a form to a mailto: or news: URL requires the UniversalSendMail privilege. For information on security in Navigator 4.0, see Chapter 7, "JavaScript Security," in the JavaScript Guide.

Description

You can use onSubmit to prevent a form from being submitted; to do so, put a return statement that returns false in the event handler. Any other returned value lets the form submit. If you omit the return statement, the form is submitted.

Event properties used

type
Indicates the type of event.

target
Indicates the object to which the event was originally sent.

Examples

In the following example, onSubmit calls the validate function to evaluate the data being submitted. If the data is valid, the form is submitted; otherwise, the form is not submitted.

<FORM onSubmit="return validate(this)">
...
</FORM>
See also the examples for Form.

See also

Submit, Form.submit

For general information on event handlers, see "General Information about Events".

For information about the event object, see event.


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 16:34:02


Copyright ?1997 Netscape Communications Corporation