onSubmit is the HTML event called when a submit button is pressed on a HTML form. The event is also called the form.submit() function is called. It can be used to trigger JavaScript to validate the form, pre-process its data, or block the submission altogether.
Here's simple onSubmit
example demonstrating its use:
<html>
<head>
<script type="text/javascript">
function greeting()
{
alert("Welcome " + document.forms["frm1"]["fname"].value + "!");
}
</script>
</head>
<body>
What is your name?<br />
<form name="frm1" action="submit.htm" onsubmit="greeting()">
<input type="text" name="fname" />
<!-- when the "Submit" button is clicked, the greeting() function above is called -->
<input type="submit" value="Submit" />
</form>
</body>
</html>