HTML onsubmit event Attribute

❮ HTML Event 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







Attribute Values

Value Description
script Specifies the script to be run on onsubmit



Technical Details

Supported HTML elements:

<>
❮ HTML Event Attributes