HTML onsubmit Attribute

❮ HTML Attributes

Example

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

Meaning

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




Standard Syntax

<element onsubmit="script">



Browser Support




Status




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