入力時にテキストエリア内の初期文字列を削除(defaultValue)
<html>
<head>
<title>入力時にテキストエリア内の初期文字列を削除</title>
<script language="JavaScript">
<!--
function foc() { //テキストエリア内が初期文字列の場合 クリア
if(document.form1.text1.value == document.form1.text1.defaultValue) {
document.form1.text1.value = "";
}
}
//-->
</script>
</head>
<body>
<form name="form1" action="" method="">
<textarea name="text1" cols="50" rows="10" onFocus="foc()">
全角2000字以内で入力してください。
(この文字は入力時に自動的に削除されます。)
</textarea><br>
</form>
</body>
</html>
〔 実行する 〕