Using the reset() method of the HTML DOM Form Object to reset the form. When this happens, the onreset event fires, which will trigger an alert function. - Javascript DOM Event

Javascript examples for DOM Event:onreset

Description

Using the reset() method of the HTML DOM Form Object to reset the form. When this happens, the onreset event fires, which will trigger an alert function.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form id="myForm" onreset="myAlertFunction()">
  First name: <input type="text" name="fname">
  <input type="button" onclick="myResetFunction()" value="Reset form">
</form>// www .j  av a2  s  .c o  m

<script>
function myResetFunction() {
    document.getElementById("myForm").reset();
}

function myAlertFunction() {
    console.log("The form was reset");
}
</script>

</body>
</html>

Related Tutorials