HTML onsubmitEvent Attributes
Examples
Run a script when a form is submitted:
<form action="demo_form.html" onsubmit="checkForm()">
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the onsubmit event attribute.
Definition and Usage
The onsubmit attribute triggers when a form is submitted.
The onsubmit attribute only applies to the <form> element.
Differences Between HTML 4.01 and HTML5
None.
Syntax
<form onsubmit="script">
Attribute Values
| Value | Description |
|---|---|
| script | Specifies the script to be executed when the onsubmit event is triggered. |
HTML Event Attributes Other Extensions