Display the text that was inserted in a text field before it was reset: - Javascript DOM Event

Javascript examples for DOM Event:onreset

Description

Display the text that was inserted in a text field before it was reset:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form onreset="myFunction()">
  <input type="text" id="myInput">
  <input type="reset">
</form>//from  ww  w .ja  v  a  2s . co m

<script>
function myFunction() {
    var x = document.getElementById("myInput");
    console.log("Before reset, the text was: " + x.value);
}
</script>

</body>
</html>

Related Tutorials