How to use Form onsubmit in JavaScript
This article describe about Form onsubmit Event in JavaScript.
Form onsubmit Event
When the submit button in a form is clicked onsubmit event occurs.
Syntax
onsubmit="JavaScriptCode"
|
Parameter |
Description |
JavaScriptCode |
Required. Specifies a JavaScript to be executed when the event occurs |
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function get() {
alert("Welcome " + document.forms["frm1"]["fname"].value + "!")
}
</script>
</head>
<body>
Enter your name?<br />
<form name="frm1" action="usegeting.htm" onsubmit="get()">
<input type="text" name="fname" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
|
Output
Note: After click on the button.
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here