The HTMLFormElement.submit()
method submits a given <form>
.
This method is similar, but not identical to, activating a form's submit <button>
. When invoking this method directly, however:
- No
submit
event is raised. In particular, the form'sonsubmit
event handler is not run. - Constraint validation is not triggered.
The HTMLFormElement.requestSubmit()
method is identical to activating a form's submit <button>
and does not have these differences.
If a form control (such as a submit button) has a name
or id
of submit
, this method will mask the form's submit method.
<input>
with attribute type="submit" will not be submitted with the form when using HTMLFormElement.submit()
, but it would be submitted when you do it with original HTML form submit.
Syntax
HTMLFormElement.submit()
Example
document.forms["myform"].submit();
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'HTMLFormElement: submit' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
submit | Chrome Full support Yes | Edge Full support 12 | Firefox Full support Yes | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes |
Legend
- Full support
- Full support