HTML onsubmitEvent Attributes

HTML 事件属性HTML Event Attributes

Examples

Run a script when a form is submitted:

<form action="demo_form.html" onsubmit="checkForm()">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onsubmit event attribute.


Definition and Usage

The onsubmit attribute triggers when a form is submitted.

The onsubmit attribute only applies to the <form> element.


Differences Between HTML 4.01 and HTML5

None.


Syntax

<form onsubmit="script">

Attribute Values

Value Description
script Specifies the script to be executed when the onsubmit event is triggered.


HTML 事件属性HTML Event Attributes Other Extensions