js判空
<script src="http://www.cnblogs.com/styles/jquery-1.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $("#login").click( function() { var loginid=document.getElementById("txtloginid"); var psw=document.getElementById("txtpsw"); if(loginid.value=="") { alert("请输入您的用户名!");return; } if(psw.value=="") { alert("请输入您的密码!");return; } $.get("http://www.cnblogs.com/common/LoginAjax.aspx?loginid="+loginid.value+"&psw="+psw.value+"&sitecode=cmjjjc", function(data){ if(data!="0") { $("#loginform").css("display","none"); $("#resultForm").css("display","block"); $("#userTD").html(data); loginid.value="";psw.value=""; window.location.href="http://www.cnblogs.com/cmjjjc_xxbs/List/index.htm"; } else { alert("您输入的用户名或者密码错误!"); } }); } );
设计
<table width="1002px" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td style="padding-top: 2px;"> <table width="1000" height="28" border="0" cellpadding="1" cellspacing="0" class="K_01"> <tr> <td width="106"> <img src="../images/login.gif" width="106" height="26" /></td> <td width="502" style="padding-left:5px;"> <table id="loginform" width="440" border="0" cellspacing="1" cellpadding="1"> <tr> <td> 用户名:</td> <td> <input id="txtloginid" type="text" name="textfield4" style=" 120px;" /></td> <td> 密 码:</td> <td> <input id="txtpsw" type="password" name="textfield2" style=" 120px;" /></td> <td width="10%"> <img src="../images/dl.gif" width="48" height="22" style="cursor:hand;" id="login" /></td> </tr> </table>