标签:
<!DOCTYPE html>
<html>
<head>
<title>Simple Login Form</title>
<meta charset="UTF-8" />
<meta name="Designer" content="PremiumPixels.com">
<meta name="Author" content="$hekh@r d-Ziner, CSSJUNTION.com">
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/structure.css">
<link href="../Scripts/easyui/themes/default/easyui.css" rel="stylesheet" />
<link href="../Scripts/easyui/themes/icon.css" rel="stylesheet" />
<link href="../Scripts/easyui/demo/demo.css" rel="stylesheet" />
</head>
<body>
<form id="login_form" class="box login">
<fieldset class="boxBody">
<label>用户名</label>
<input id="userId" type="text" tabindex="1" placeholder="" required>
<label><a href="#" class="rLink" tabindex="5"></a>密码</label>
<input id="userPwd" type="password" tabindex="2" required>
</fieldset>
<footer>
<input type="submit" class="btnLogin" value="登 录" tabindex="4">
</footer>
</form>
<footer id="main">
<a href="http://wwww.cssjunction.com">新烽光电股份有限公司</a> | <a href="http://www.premiumpixels.com">制作 by 软件部</a>
</footer>
</body>
</html>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../Scripts/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../Scripts/easyui/locale/easyui-lang-zh_CN.js"></script>
<script>
document.getElementById("login_form").onsubmit = function () {
requiredCheck();
return false;
};
function requiredCheck() {
var userModel = {
userId: $.trim($("#userId").val()),
userPwd: $.trim($("#userPwd").val())
};
for (var i in userModel) {
if (userModel.hasOwnProperty(i)) {
if (userModel[i] == "") {
$.messager.alert(‘提示‘, ‘用户名或密码不能为空‘, "error");
return false;
}
}
}
$.post("/Login/LoginCheck.ashx", userModel, function (msg) {
if (msg.code == 0) {
$.messager.alert(‘提示‘, msg.result, "error");
} else {
window.location.href = "/index.aspx";
}
});
}
</script>
注意: 注册form表单的onsubmit事件,return false(在事件处理函数(onsubmit)里面return false)来阻止表单提交,
标签:
原文地址:http://www.cnblogs.com/gaocong/p/5749998.html