Form reset()Method
Form Object
Definition and Usage
The reset() method can reset the values of all elements in a form (same effect as clicking the Reset button).
Syntax
formObject.reset()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the reset() method
Example
Example
Create a reset button for a form:
<html>
<head>
<script>
function formReset()
{
document.getElementById("frm1").reset();
}
</script>
</head>
<body>
<form id="frm1">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formReset()" value="Reset form">
</form>
</body>
</html>
<head>
<script>
function formReset()
{
document.getElementById("frm1").reset();
}
</script>
</head>
<body>
<form id="frm1">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="button" onclick="formReset()" value="Reset form">
</form>
</body>
</html>
Try it Yourself »
Form Object Other Extensions