HTML onsubmit Event Attribute
Example
Execute a JavaScript when the form is submitted:
<form action="demo_form.asp" onsubmit="checkForm()">
Browser Support
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
All major browsers support the onsubmit attribute.
Definition and Usage
The onsubmit attribute triggers when a form is submitted.
The onsubmit attribute is only used in <form>.
Differences between HTML 4.01 and HTML5
None.
Syntax
<form onsubmit="script">
Attribute Value
Value | Description |
---|---|
script | Script executed when onsubmit occurs. |