![]() |
Definition and UsageThe Applies toThe
Browser Support |
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<p>When you submit the form, a function is triggered which alerts some text.</p>
<form action="/action_page.php" onsubmit="myFunction()">
Enter name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
<script>
function myFunction() {
alert("The form was submitted");
}
</script>
</body>
</html>
html onsubmit attribute |
How to Execute a JavaScript when a form is submitted - HTML onsubmit Attribute | HTML Attribute |
Read Full: | HTML Attribute |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Attribute |
Uploaded by: | Admin |
Views: | 40 |
Reffered: https://www.w3schools.com/tags/att_onsubmit.asp