▼入力欄には、入力のヒントとなるテキストが表示されています。このヒントテキストは入力欄をクリックすると消えます。入力欄からフォーカスを外すと、入力欄が空の場合、ヒントテキスト以外のテキストが入力されていない場合は、再度ヒントテキストが透かし表示されます。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="ja" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<title>Watermark Input Plugin | 設置サンプル</title>
<link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
<!-- JS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="/content/lib/jquery/jquery.watermarkinput.js"></script>
<script type="text/javascript">
$(function($){
$("#username").Watermark("ユーザー名","#999");
$("#password").Watermark("パスワード","#999");
$("#email").Watermark("example@example.co.jp","#999");
});
</script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="/content/lib/jquery/jquery.jqpuzzle.css" />
<style type="text/css">
input#username, input#password { width:10em; }
input#email { width:15em; }
</style>
<link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
<body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP & JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
<div id="wrap">
<h1 id='a_watermaerk_input_plugn'><a href='http://digitalbush.com/projects/watermark-input-plugin/'>Watermark Input Plugin</a> | 設置サンプル</h1>
<p>▼入力欄には、入力のヒントとなるテキストが表示されています。このヒントテキストは入力欄をクリックすると消えます。入力欄からフォーカスを外すと、入力欄が空の場合、ヒントテキスト以外のテキストが入力されていない場合は、再度ヒントテキストが透かし表示されます。</p>
<!-- CODE -->
<form action="#">
<fieldset>
<legend>ユーザー登録</legend>
<p>
<label for="username">ユーザー名</label>
<input type="text" id="username" name="username" />
<label for="password">パスワード</label>
<input type="password" id="password" name="password" />
<label for="email">E-mail</label>
<input type="text" id="email" name="email" />
</p>
<p>
<input type="button" onclick="$.Watermark.HideAll()" value="すべてクリア" />
<input type="button" onclick="$.Watermark.ShowAll()" value="すべて表示" />
</p>
</fieldset>
</form>
<!-- / CODE -->
</div>
</body>
</html>