フォーム内容の消去(リセット)

書式

Form.reset(form)

form : フォームオブジェクト

説明

フォーム内容の消去(リセット)するにはForm.reset()メソッドを使います。パラメータにはリセットしたいフォームのオブジェクトを指定します。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
function resetForm() {
Form.reset("userData");
}
// --></script>
</head>
<body>
<h1>フォームのリセット</h1>
<form id="userData">
番号:<input type="text"><br>
名前:<input type="text"><br>
住所:<input type="text"><br>
<input type="button" value="消去" onClick="resetForm()">
</form>
</body>
</html>