<html> <head> <meta http-equiv="content-type" content="text/html;charset=GB2312"/> <title> 4.6 人性化表单 </title> <!--脚本部分--> <script type="text/javascript"> function $(str) {return(document.getElementById(str));} function check_submit(){ if($("txt_user_name").value==""){alert("请填写username");return(false);} if($("txt_user_pass").value==""){alert("请输入password");return(false);} if($("txt_user_pass_confirm").value=="") {alert("请输入确认password");return(false);} $("submit_button").disabled=true; return(false); } function mover(){ event.srcElement.focus(); event.srcElement.select(); } function mblur(){ if(event.srcElement.value=="") event.srcElement.value="[输入username]"; } function mclick(){ if(event.srcElement.value=="[请输入username]") event.srcElement.value=""; } </script> </head> <body style="overflow:auto;"> <form action="" onsubmit="return check_submit();"> username: <br> <input id="txt_user_name" onmouseover="mover(); onclick="mclick();" onblur="mblur();" value="[请输入username]"><br> password: <br> <input id="txt_user_pass" type="password" onmouseover="mover();" value="默认password"><br> 确认password:<br> <input id="txt_user_pass_conform" type="password" onmouseover="mover();" value="默认password"><br> <input type="submit" calue="提交" id=submit_button"> </form> </body> </html>