首先看下面要使用HTML自动聚焦和占位文本的示例代码
1: <!DOCTYPE html>
2: <html>
3: <head>
4: <title>注册帐号</title>
5: <meta charset="utf-8">
6: </head>
7: <body>
8:
9: <form method="post" action="goto">
10: <fieldset id="register_information">
11: <legend>新用户注册</legend>
12: <ol>
13: <li>
14: <label for="name">邮 箱</label>
15: <input type="email" id="name" name="name">
16: </li>
17: <li>
18: <label for="user"> 用户名</label>
19: <input type="text" id="user" name="user">
20: </li>
21: <li>
22: <label for="nickname"> 显示名称</label>
23: <input type="text" id="nickname" name="user">
24: </li>
25: <li>
26: <label for="password">密码</label>
27: <input type="password" id="password" name="user_password">
28: </li>
29: <li>
30: <label for="confirm_password">确认密码</label>
31: <input type="password" id="confirm_password" name="user_password">
32: </li>
33: </ol>
34:
35: </fieldset>
36:
37: </form>
38:
39: </body>
40: </html>
<li>
<label for="name">邮 箱</label>
<input type="email" id="name" name="name" autofocus>
</li>
<ol>
<li>
<label for="name">邮 箱</label>
<input type="email" id="name" name="name" autofocus placeholder="请输入有效的邮件地址">
</li>
<li>
<label for="user"> 用户名</label>
<input type="text" id="user" name="user" placeholder="输入用户名">
</li>
<li>
<label for="nickname"> 显示名称</label>
<input type="text" id="nickname" name="user" placeholder="输入昵称">
</li>
<li>
<label for="password">密码</label>
<input type="password" id="password" name="user_password" placeholder="输入密码">
</li>
<li>
<label for="confirm_password">确认密码</label>
<input type="password" id="confirm_password" name="user_password" placeholder="再次输入密码">
</li>
</ol>
<input type="password" id="password" name="user_password" autocomplete="off" placeholder="输入密码">