Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>Enter some text in the field below, then press the "Reset form" button to reset the form.</p> <form id="myForm" onreset="myAlertFunction()"> First name: <input type="text" name="fname"> <input type="button" onclick="myResetFunction()" value="Reset form"> </form> <p>The reset() method of the HTML DOM Form Object resets the values of all elements in a form. When this happens, the onreset event fires, which will trigger the alert function.</p> <script> // Reset the text of an element in a form with id="myForm" function myResetFunction() { document.getElementById("myForm").reset(); } // Alert some text when the form is reset function myAlertFunction() { alert("The form was reset"); } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onreset3 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:29:51 GMT --> </html>
Result:
Try it Yourself - © w3schools.com