In this JavaScript Tutorial, we will create a simple HTML form with three text fields in it. Then we will handle the form level events onsubmit and onreset. These events are fired when the user clicks the submit or reset button in the form.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>Java Script - Submit and Reset</title> </head> <!-- <body text="blue"> --> <body> <h1> Javascript Tutorial: OnSubmit & OnReset Example</h1> <form action="DummyAction.html" onsubmit="confirm('Do you want to submit?')" onreset="confirm('Form Fields will be cleared!\r\nAre you sure?')" > <h3> Enter Your Name</h3> First Name: <input type="text" name="FirstName"/><br/> Middle Name: <input type="text" name="MiddleName"/><br/> Last Name: <input type="text" name="LastName"/><br/> <input type="submit" /> <input type="reset" /> </form> </body> </html> |
Categories: JavaScript-Tube