当前位置: 代码迷 >> Java Web开发 >> 关于jsp中使用js的有关问题?求解
  详细解决方案

关于jsp中使用js的有关问题?求解

热度:3050   发布时间:2016-04-11 00:07:31.0
关于jsp中使用js的问题?求解
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
  <head>
    <title>My JSP 'Verify.jsp' starting page</title>
    <script type = "text/javascript">
                
                function Verify()
                {
                 var username = document.getElementById("username");
                    var password = document.getElementById("password");
                    var repassword = document.getElementById("repassword");
                    
                     if(username.value.length == 0)
                      {
                      //alert(typeof username);
                       alert("用户名不能为空");
                       return false;
                      }
                      if(password.value.length <=6 || password.value.length >= 15)
                      {
                      // alert(password.value);
                       alert("length of password can't invalid");
                       return false;
                      }
                      if(repassword.value.length <=6 || repassword.value.length >= 15)
                        {
                      alert("length of repassword can't invalid");
                      return false;
                        }
                      if(password.value != repassword.value)
                      {
                      alert("repassword is not same with password");
                      return false;
                      }
                
                 return true;
                }
        </script>
  </head>
  <body>
        <form onsubmit = "return Verify()">
        username:&nbsp;&nbsp;<input type = "text" name = "username" id = "username"/><br/>
        password:&nbsp;&nbsp;<input type = "text" name = "password" id = "passsword"/><br/>
        repassword:<input type = "text" name = "repassword" id = "repassword"/> <br/>
  相关解决方案