Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to call a JavaScript function on submit form?
The onsubmit event occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data.
<script>
<!--
function validation() {
all validation goes here
.........
return either true or false
}
//-->
</script>
The HTML code snippet.
<form method="POST" action="new.cgi" onsubmit="return validate()"> … <input type="submit" value="Submit" /> </form>
Advertisements
