English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The submit event will be triggered when the user clicks the submit button ( <input type="submit"/> Element is triggered when the form is submitted.
Run onsubmit when the form is submitted:
<!DOCTYPE html> <html> <head> <title>HTML onsubmit event attribute usage (Basic Tutorial Website oldtoolbag.com)</>title </>head <body> <p>After submitting the form, a prompt box will pop up.</>p <form action="demo-form.php" onsubmit="myFunction()"> Enter Name: <input type="text" name="fname"> <input type="submit" value="Submit"> </form> <script> function myFunction() { alert("Form is submitted"); } </script> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the onsubmit event attribute
The onsubmit attribute is triggered when a form is submitted.
The onsubmit attribute is only applicable to <form> elements.
No difference.
<form onsubmit="script">
Value | Description |
---|---|
script | Specifies the script to be executed when the onsubmit event is triggered. |