Search w3schools.com:

SHARE THIS PAGE

Form reset() Method

Form Object Reference Form Object

Definition and Usage

The reset() method resets the values of all elements in a form (same as clicking the Reset button).

Syntax

formObject.reset()


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The reset() method is supported in all major browsers.


Example

Example

Create a button that resets the 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>

Try it yourself »


Form Object Reference Form Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]