Form reset() Method - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form

Description

The reset() method resets the values of all elements in a form.

The following code shows how to Reset a form:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>


<form id="myForm">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br><br>
  <input type="button" onclick="myFunction()" value="Reset form">
</form>/*from   w  w  w .  j  av a2  s  .  c  o m*/

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

</body>
</html>

Related Tutorials