程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> javascript-jsp新人求助,登錄頁面設定驗證碼和密碼確認之後,在表單內提交前校驗完全沒響應

javascript-jsp新人求助,登錄頁面設定驗證碼和密碼確認之後,在表單內提交前校驗完全沒響應

編輯:編程綜合問答
jsp新人求助,登錄頁面設定驗證碼和密碼確認之後,在表單內提交前校驗完全沒響應
 <%@ page  language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import = "java.util.*" %>
<%@ page import = "util.*" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>登錄頁面</title>
    <script language = "JavaScript" type = "text/javascript">
//          (function(){
//  var sub = document.getElementById("sub");
    //初始化移入移出事件
    //if(sub.addEventListener){
        //sub.addEventListener("click", check); 
    //}else if(sub.attachEvent){
    //  sub.attachEvent("onClick", check);
    //}
//})();

    function check(f){
        var pwd = f.upass.value;
        var acpwd = f.acupass.value;
        var vc = f.yanzheng.value;
        var vcode = f.img.value;
        boolean ret = true;
        if(pwd != acpwd){
            alert("兩次密碼不相同!!!");
            ret = false;
            window.location.reload;
        }else if(vcode != vc)){
                alert("驗證碼不對!!!");
                ret = false;
                window.location.reload;
            }else{
            document.forms[0].submit();
            }
            return ret;
        }
    </script>

  <body>
    <from action = "LoginServ" method = "post" name = "loginform" onSubmit = "return check(this)">
        用戶名:&nbsp;&nbsp;<input type="text" name="id"/><br/>
         密&nbsp;&nbsp;碼:
         <input type="password" name="upass" id="upass"/><br/>
                     確認密碼:<input type="password" name="acupass" id="acupass"/><br/>
         驗證碼:
         <input type="text" name="excode" id="yanzheng"/>
         <%
            Tools t = new Tools();
            String vcode = t.ExperimentCode();
          %>
         <img src="/WebBook/images/vcode.png" id = "img"/><br/>

         <input type="radio" name="identity" value="con" checked="checked" />買家
         <input type="radio" name="identity" value="sel" />賣家


         <input id = "sub" type="submit" value="登錄"/>&nbsp;&nbsp;
         <input type="reset" value="清空"/>
    </from>
  </body>
</html>

最佳回答:


語法都錯了,js和java混用了

        function check(f) {
            var pwd = f.upass.value;
            var acpwd = f.acupass.value;
            var vc = f.yanzheng.value;
            var vcode = f.img.value;
            var ret = true;///js沒有boolean關鍵字
            if (pwd != acpwd) {
                alert("兩次密碼不相同!!!");
                ret = false;
                window.location.reload;
            } else if (vcode != vc)/*)這裡多了個反括號*/ {
                alert("驗證碼不對!!!");
                ret = false;
                window.location.reload;
            } else {
                document.forms[0].submit();
            }
            return ret;
        }
u013436339
showbo
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved