onsubmit Event
Example
Execute a JavaScript when a form is submitted:
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
Try it Yourself »
Definition and Usage
The onsubmit event occurs when a form is submitted.
Browser Support
Event | |||||
---|---|---|---|---|---|
onsubmit | Yes | Yes | Yes | Yes | Yes |
Syntax
In JavaScript, using the addEventListener() method:
object.addEventListener("submit", myScript);
Try it Yourself »
Technical Details
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | Event |
Supported HTML tags: | <form> |
DOM Version: | Level 2 Events |