<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<script type="text/javascript">
function check(){
var username=document.getElementById("userName").value;
var password=document.getElementById("passWord").value;
if(username.length<=0){
alert("用户名不能为空");
return false;
}
if(password.length<=0){
alert("密码不能为空");
return false;
}
if(username.valueOf()==" "){
alert("用户名不能为空格")
return false;
}
if(password.valueOf()==" "){
alert("密码不能为空格")
return false;
}
from1.submit();
}
function checks(){
var username=document.getElementById("userName").value;
var password=document.getElementById("passWord").value;
if(username.length<=0){
alert("用户名不能为空");
return false;
}
if(password.length<=0){
alert("密码不能为空");
return false;
}
if(username.valueOf()==" "){
alert("用户名不能为空格")
return false;
}
if(password.valueOf()==" "){
alert("密码不能为空格")
return false;
}
alert("验证通过")
document.loginForm.submit();
}
</script>
<body>
<form name="from1" action="${pageContext.request.contextPath}/login.do?operate=login" method="post" >
username:<input type="text" name="userName"/><br>
password:<input type="text" name="passWord"><br>
<input type="button" name="button" value="tijiao" οnclick="check()">
</form>
<html:form action="/login.do?operate=login" method="post">
username:<html:text property="userName" ></html:text>
password:<html:password property="passWord"></html:password>
<input type="button" name="button" value="提交" οnclick="checks()">
</html:form>
</body>
</html>
用户名判断以及跳转
最新推荐文章于 2017-10-11 01:21:39 发布