Form.reset()

JavaScript 1.1+, JScript 1.0+ Nav3+, IE 3+, Opera3+ Syntax

							form.reset()

Description

The reset method of the Form object resets all the form elements to their default values. It operates the same as a mouse click on a Reset button for the calling form.

Example

Listing 7.265 shows how the reset method is used to reset a form. When the Reset button is clicked, all values in the form object are reset (text boxes are cleared of their values).

Listing 7.265 Accessing the reset() Method
<html>
<head>
<title> Using the reset method of the Form object</title>
</head>
<body>
<script language="JavaScript">
<!-- Hide
function resetForm(form){
     document.form1.reset(form);
}
// End Hide --->
</script>
							 <form name="form1"> Field 1:<input ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.