HTML onsubmit Attribute

❮ HTML Attributes


<form action="action.php" onsubmit="myFunction()">
	Enter name: <input type="text" name="fname">
	<input type="submit" value="Submit">


The onsubmit attribute specifies the script run when a form is submitted.

Standard Syntax

<element onsubmit="script">

Browser Support


Applies to:

The onsubmit attribute can be used on the following element:

Element Attribute
<form> onsubmit

Attribute Values

Value Description
script Specifies the script to be run on onsubmit
❮ HTML Attributes