Call a function when a form is submitted:
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
Try it Yourself »
The onsubmit event occurs when a form is submitted.
Event | |||||
---|---|---|---|---|---|
onsubmit | Yes | Yes | Yes | Yes | Yes |
In JavaScript, using the addEventListener() method:
object.addEventListener("submit",
myScript);
Try it Yourself »
Bubbles: | Yes |
---|---|
Cancelable: | Yes |
Event type: | Event |
HTML tags: | <form> |
DOM Version: | Level 2 Events |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!