Get your own website Result Size: 625 x 565
x
 
<!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>
</html>