w3schools    w3Schools
Search :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
HTML DOM
DOM HOME
DOM Intro
DOM Nodes
DOM Node Tree
DOM Methods
DOM Node Access
DOM Node Info
DOM How To
DOM Events
DOM Reference
DOM Summary

DOM Examples
DOM Examples

DOM Objects
DOM Window
DOM Navigator
DOM Screen
DOM History
DOM Location

DOM Document

DOM Anchor
DOM Area
DOM Base
DOM Body
DOM Button
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM IFrame
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Meta
DOM Object
DOM Option
DOM Select
DOM Style
DOM Table
DOM TableCell
DOM TableRow
DOM Textarea

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

Browse Tutorials
 

onsubmit event


Event Object Reference Complete Event Object Reference

Definition and Usage

The onsubmit event occurs when the submit button in a form is clicked.

Syntax

onsubmit="SomeJavaScriptCode"

Parameter Description
SomeJavaScriptCode Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<form>

Supported by the following JavaScript objects:

form


Example

In this example an alert box will be displayed when the user clicks on the submit button:

<html>
<head>
<script type="text/javascript">
function welcome()
{
alert("Welcome " + document.forms["myform"]["fname"].value + "!")
}
</script>
</head>
<body>
What is your name?<br />
<form name="myform" action="submit.htm" onSubmit="welcome()">
<input type="text" name="fname" size="20">
<input type="submit" value="Submit">
</form>
</body>
</html>

The output of the code above will be:

What is your name?


Try-It-Yourself Demos

onsubmit
How to use onsubmit.


Event Object Reference Complete Event Object Reference