<div class="codetitle"> <span><a style="CURSOR: pointer" data="96050" class="copybut" id="copybut96050" onclick="doCopy('code96050')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code96050"> <br><script src="jquery-1.9.1.js">< /script> <BR><script type="text/javascript"> <BR>$('#txtUserName').focus(function () { <BR>$('#txtUserName').val(''); <BR>}) <BR>$('#txtPassWord').focus(function () { <BR>$('#txtPassWord').val(''); <BR>}) <BR>$(' #txtUserName').blur(function () { <BR>if ($('#txtUserName').val() =='') <BR>{ <BR>$('#txtUserName').val('使用者名稱不能為空白'); <BR>//重新取得焦點<BR>// $('#txtUserName').focus(); <BR>} <BR>}) <BR>$('#txtPassWord ').blur(function () { <BR>if ($('#txtPassWord').val() == '') { <BR>$('#txtPassWord').val('密碼不能為空' ); <BR>} <BR>}) <BR>$('#btnSubmit').click(function () { <BR>if ($('#txtUserName').val() == 'admin' &&& $('#txtPassWord').val() == '888888') <BR>{ alert('登陸成功!'); } <BR>else { alert('登陸失敗!'); } <BR>} ) <BR>}) <BR></script> <br> <br> <br>用戶名:<input id="txtUserName" type="text" value="請輸入用戶姓名"><br> <br>密碼:<input id="txtPassWord" type="text" value="請輸入密碼"><br> <br><input id="btnSubmit" type="button" value="btnSubmit"> <br> <br> </div>