HTML onsubmit attribute
onsubmit
The purpose of the HTML onsubmit attribute is to execute the code specified, when the associated form is submitted.
Supported elements
HTML onsubmit attribute supports form element.
Syntax
<form onsubmit="value" >.....</form>
Type of value
Script.
Value
A script which is to be executed.
Default value
There is no default value of HTML onsubmit attribute.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML onsubmit attribute with form
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML onsubmit attribute with form</title>
</head>
<body>
<form name="user_info" onsubmit="alert('The form is submitted')" action="">
Name : <input type="text" name="name"><br>
email : <input type="text" name="email"><br>
Describe yourself : <br/>
<textarea rows="10" colos="10" name="describe_yourself">
</textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML onsubmit attribute with form element
Previous: HTML onselect attribute
Next: HTML onunload attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html/attributes/html-onsubmit-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics