onsubmit Event
Example
Call a function when a form is submitted:
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
Try it Yourself »
Description
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 |
HTML tags: | <form> |
DOM Version: | Level 2 Events |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.