|
| JAVASCRIPT ONSUBMIT EVENT
The javascript onsubmit event handler is used to trigger a script or action when a form is submitted ie when the submit button is depressed. The onsubmit event calls the action from the <form> element.
Example:
<form action="#" method="post" onsubmit="alert('You are submitting a form now');">
<input type="text" ><br>
<input type="submit" value="submit" >
</form>
The above example will output You are submitting a form now when you press the submit button.
The onsubmit event can also call a function as follows:
<head>
<script type="text/javascript">
function submitme ()
{
alert('You are submitting a form now');
}
</script>
</head>
<body>
<form action="#" method="post" onsubmit="submitme();">
<input type="text" ><br>
<input type="submit" value="submit" >
</form>
DEMO:
Click the submit buttom below to see the effect.
See also:
|
|