<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>