Form reset()Method

Form 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

Try it Yourself »


Form 对象参考手册Form Object Other Extensions