<!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>
function myResetFunction() {
document.getElementById("myForm").reset();
}
function myAlertFunction() {
alert("The form was reset");
}
</script>
</body>
</html>