HTML onsubmit Event Attribute HTML Reference



Example

Execute a JavaScript when a form is submitted:

<form action="my_form.php" onsubmit="checkForm()">

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

The onsubmit attribute fires when a form is submitted.

The onsubmit attribute is only used within: <form>.


2. Differences Between HTML 4.01 and HTML5

None.


3. Syntax

<element onsubmit="script">

4. Attribute Values

Value Description
script The script to be run on onsubmit

Relative articles