This event gets fired when user clicks on the submit button. a form contains submit button which contains the onsubmit event. When this button is clicked this event gets fired. |
Example: |
<html>
<head> <title>events </title> </head> <body bgcolor=red text=”white” > <form name=”sandeep” onsubmit=”alert(‘got submitted’)”> Name : <input type=”text” name=t1 id=”tt1″ > <br> Address : <input type=”text” name=t2 > <br> <input type=”submit” name=”b1″> <br> </form> </body> </html> |
click here to view results of this program on browser |
Example: |
<html>
<head> <title>events </title> </head> <body bgcolor=red text=”white” > <form name=”sandeep” onsubmit=”ff()”> Name : <input type=”text” name=t1 id=”tt1″ > <br> Address : <input type=”text” name=t2 > <br> <input type=”submit” name=”b1″> <br> </form> <script> function ff() { alert(“The value being set is ” +document.all.tt1.value) } </script> </body> </html> |