w3resource logo

JavaScript Form Object - submit method

JavaScript Form Object : submit Method()


Seondary Nav


The submit() method of the form object is used to submit the specified form. It behaves the same as if a submit button was clicked.


Implemented in JavaScript 1.0





Example of Form Object : submit method()

In the following web document submit method is used to submit a form.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JavaScript form object - submit method example</title>
<h1 style="color: red">JavaScript form object : submit method</h1>
<h3> Click on the submit button to submit the form.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
function submitForm(form){
<form name = "form1"  method = "post"  action = "../../javascript/client-object-property-method/thankyou.html">
Input your name and address
<br /><br />
Name :  <input type="text" size="40" name="name" />
<br /><br />
Address : <input type="text" size="40" name="age" />
<input type="text" size="35" name="phone" />
<br /><br />
<input type= "button" value="Submit" onclick = "submitForm(this.form)" />

View the example of form object's submit method in the browser

Supported Browser

Internet Explorer 7 Firefox 3.6 Google Chrome 7 Safari 5.0.1 Opera 10
Yes Yes Yes Yes Yes

See also :

JavaScript Client side objects, methods, properties.

JavaScript Core objects, methods, properties.


Looking for some other tutorial?