- <%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/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>登录界面</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 language="JavaScript">
- function Validate()
- {
- //得到用户 输入的信息
- userid=form.userid.value;
- userpass=form.userpass.value;
- //判断用户名的长度
- if(!maxLength(userid,12))
- {
- alert("拥护名长度大于12!");
- form.userid.focuse();
- return false;
- }
-
- if(!maxLength(userpass,12))
- {
- alert("密码长度大于12!");
- form.userpass.focuse();
- return false;
- }
-
- //判断拥护名和密码是否一致
- if(userid==userpass)
- {
- alert("拥护名和密码不能相同");
- form.userpass.focuse();
- return false;
- }
- return true;
- }
- //验证是否满足最小长度
- function minLength(str,length)
- {
- if(str.length>=length)
- return true;
- else
- return false;
- }
- function maxLength(str,length)
- {
- if(str.length<=length)
- return true;
- else
- return false;
- }
-
- window.open("http://www.baidu.com","window2")
-
- </script>
- <body>
- <form action="MyJsp2.jsp" onsubmit="return Validate();" method="post">
- 用户名:<input type="text" name="userid"><br>
- 密码:<input type="password" name="userpass"><br>
- <input type="reset" value="重填" >
- <input type="submit" value="确定">
- </form>
- </body>
- </html>
复制代码 上来是代码。。。
|
|