onsubmitEvent

事件对象参考手册Event Object

Example

Execute JavaScript when the form is submitted:

<form action="demo-form.php" onsubmit="myFunction()">Enter name:<input type="text" name="fname"> <input type="submit" value="Submit"> </form>

Try it yourself »


Definition and Usage

The onsubmit event triggers when a form is submitted.


Browser Support

Event
onsubmit Yes Yes Yes Yes Yes


Syntax

In HTML:

<element onsubmit="myScript">Try it

In JavaScript:

object.onsubmit=function(){myScript};Try it

In JavaScript, using the addEventListener() method:

object.addEventListener("submit", myScript);Try it

Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()the method.


Technical Details

Bubbles: Yes
Cancelable: No
Event type: Event
Supported HTML tags: <form>, <keygen>


事件对象参考手册Event Object

Other Extensions