4 回答

TA贡献1条经验 获得超0个赞
这是登录页面
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
href="${pageContext.request.contextPath }/css/Loginhtwl.css" />
<script type="text/javascript"
src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
</head>
<body>
<div id="box">
<div id="login">
<form name="form"
action="<%=request.getContextPath()%>/HTWLdoLoginservlet"
method="post">
<p id="msg">
<%
if (request.getAttribute("mess") != null) {
out.print(request.getAttribute("mess").toString());
}
%>
</p>
<input type="text" name='username' class='text username' value="请输入帐号" /> <input type="password" name='password'class='text passwrd' value="" />
<input type="button" name='sub' class='btn' value="" id="mouse" onclick="login()"/>
</form>
</div>
</div>
<script type="text/javascript">
var $username = $("[name='username']");
var $password = $("[name='password']");
$(function() {
//把name得到对象
$username.focus(function() {
if ($username.val() == "请输入帐号") {
$username.val("");
}
});
$username.blur(function() {
if ($username.val() == "") {
$username.val("请输入帐号");
}
});
});
//提交按钮点击时
function login() {
if ($username.val() == "请输入帐号" || $password.val() == "") {
$("#msg").addClass("color", "red").text("用户名和密码不为空!");
} else {
$("#msg").css("color", "aquamarine").text("开始登录!");
/* $("[name='form']").form.submit(); */
document.form.submit();
}
}
//登录
$(function(){
$(document).keydown(function(event) {
if (event.keyCode == 13) {
$("#mouse").click();
}
});
$("#mouse").click(function() {
document.form.submit();
});
})
</script>
</body>
</html>
添加回答
举报