Display the text that was inserted in a text field before it was reset:
Write something in the text field and press the Reset button.
<!DOCTYPE html> <html> <body> <form onreset="myFunction()"> <input type="text" id="myInput"> <input type="reset"> </form>/*from w ww .j av a 2s.c o m*/ <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myInput"); document.getElementById("demo").innerHTML = "Before reset, the text was: " + x.value; } </script> </body> </html>