87,910
社区成员
发帖
与我相关
我的任务
分享
<form name="login" action="target.html" method="post">
Username<input type="text" name="userid"/><br/>
Password<input type="password" name="pswrd"/><br/>
<input type="submit" value="Login">
</form>
<!--登录界面admin_login-->
<div class="main">
<form id="login_form" action="Handel/Ulogin.ashx">
<div class="login_userid">
<span>账 号:</span>
<input name="userid" type="text" class="input" id="userid" autocomplete="off" />
</div>
<div class="login_password">
<span>密 码:</span>
<input name="password" type="password" class="input" id="password" />
</div>
<div class="login_code">
<span>验证码:</span>
<input name="code" type="text" class="input" id="code" style="width:50px;" maxlength="4" autocomplete="off" />
<img alt="" src="../Control/validate.aspx" id="getcode_img" title="看不清请点击!" />
</div>
<div class="login_button">
<input type="button" name="submit" id="submit" value="" onclick="submit_login();" /> <!--调用执行登录js_login.js-->
<input type="reset" name="reset" id="reset" value="" onclick="doReset();" />
</div>
</form>
<div class="note">
* 不要在公共场合保存登录信息;<br />
* 为了保证您的帐号安全,退出系统时请注销登录
<span id="msg_tip"></span>
</div>
</div>
//登录页面admin_login的执行方法
protected void Page_Load(object sender, EventArgs e)
{
if (CheckAdminLogin())
Response.Redirect("~/admin/admin.aspx");
}
/*
*js_login.js
*/
function submit_login(){
var admin_uname=$("#userid").val();
var admin_psw=$("#password").val();
var admin_yzm=$("#code").val();
if(admin_uname==""){
alert("请输入您用户账号!");
$("#userid").focus();
return false
}
if(admin_psw==""){
alert("请输入您的登录密码!");
$("#password").focus();
return false
}
if(admin_yzm==""){
alert("验证码不能为空!");
$("#code").focus();
return false
}
if(document.getElementById("code").value.length!=4){
alert("您输入的验证码不合理!");
$("#code").select();
return false
}
$.ajax({
type: "get", /*get方法异步传输,进入adminlogin.aspx页面进而执行操作*/
url: "../ajax/adminlogin.aspx?paramName=" + escape(admin_uname) + "¶mPwd=" + admin_psw + "&validate=" + admin_yzm,
eache: false,
success: function(reg){
var arr=reg.split('|');
var returnval=arr[0].toString();
var tip=arr[1].toString();
if(returnval=="15")
{
$("#msg_tip").text(tip);
document.getElementById("code").value="";
$("#code").focus();
ShowValidImage();
return false;
}
if(returnval=="3")
{
$("#msg_tip").text(tip);
document.getElementById("userid").value="";
document.getElementById("password").value="";
ShowValidImage();
return false;
}
else if(returnval=="9")
{
$("#msg_tip").text(tip);
document.getElementById("userid").select();
document.getElementById("code").value="";
ShowValidImage();
return false;
}
else if(returnval=="14")
{
$("#msg_tip").text(tip);
document.getElementById("userid").select();
document.getElementById("code").value="";
ShowValidImage();
return false;
}
else if(returnval=="20" || returnval=="30")
{
$("#msg_tip").text(tip);
document.getElementById("userid").value="";
document.getElementById("password").value="";
document.getElementById("code").value="";
document.getElementById("userid").focus();
return false;
}
else if(returnval=="10")
{
$("#msg_tip").text("");
window.location.href="admin.aspx";
}
},
error: function(){
$("#msg_tip").text("参数出错,请与管理员联系!");
ShowValidImage();
document.getElementById("code").value="";
}
});
}
function doReset() {
ShowValidImage();
$("#userid").focus();
}
//更换验证码
function ShowValidImage() {
var numkey = Math.random()+(new Date().getDate());
document.getElementById("getcode_img").src = "../control/validate.aspx?NumKey="+numkey;
}
接下来就是adminlogin的一些一般方法:是否登录,获取传入值,对比加密pwd、uid 的一些东西了。