|
|
The HTML
onsubmit event attribute is an event handler that is triggered when an HTML form is submitted. This event fires on the <form> element itself, not on the submit button or input that initiates the submission.
|
<form onsubmit="myFunction()">
Enter name: <input type="text">
<input type="submit">
</form>
The onsubmit attribute fires when a form is submitted.
<form onsubmit="script">
| Value | Description |
|---|---|
| script | The script to be run on onsubmit |
| Supported HTML tags: | <form> |
|---|
When you submit the form, a function is triggered which alerts some text.
<!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 event attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Form Events Attribute |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference