Advertisement
Home Open Editor ❯

HTML onsubmit Attribute

Example

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

Try this code ❯

Meaning

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


Standard Syntax

<element onsubmit="script">


Applies to:

The onsubmit attribute can be used on the following element:

Element Attribute
<form> onsubmit

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on onsubmit
Home Open Editor ❯
Advertisement