跳到内容(1) Cob.com.cn

教程·Javascript 中文手册

您的位置:首页>>教程>>Javascript手册

onSubmit

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

事件适用对象 Navigator 2.0

语法

onSubmit="handlerText"

参数

handlerText JavaScript 代码或对一个 JavaScript 函数的调用。

安全性

Navigator 4.0: Submitting a form to a mailto: or news: URL requires the UniversalSendMail privilege. 要获取 Navigator 4.0 中关于安全性更多的信息,请看第七章“JavaScript 安全性”

描述

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.

使用的事件属性

type 标明了事件的类型。
target 标明了事件原来发送的对象。

示例

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示例 forForm

参看

Form.submit 要获得关于事件句柄的常规信息,请看“事件的常规信息”

要获得关于事件对象的信息,请看事件

End Nav