Jacklovely

导航

 
 1 <!DOCTYPE html>
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5     <title>表单事件</title>
 6     <script type="text/javascript">
 7         //表单焦点失去、获得
 8         onload = function () {
 9             var txt = document.getElementById("txt");
10             txt.onblur = function () {
11                 if (txt.value == "") {
12                     txt.value = "如123abc@163.com";
13                 }
14             }
15             txt.onfocus = function () {
16                 if (txt.value == "如123abc@163.com") {
17                     txt.value = "";
18                 }
19             }
20         }
21     </script>
22 </head>
23 <body>
24     <form id="fm">
25         <!--有时提交会出现405错误,可能与name,value,id有关-->
26         <input type="text" name="uid" value="" id="txt" /><br />
27         <input type="password" name="pwd" value="" /><br />
28         <input type="submit" value="提交" id="btn1" /><br />
29     </form>
30 
31 </body>
32 </html>

 

posted on 2016-04-15 10:43  Jacklovely  阅读(420)  评论(0编辑  收藏  举报