锁链之亡灵
2015-11-02 14:00
采纳率: 50%
浏览 2.5k

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>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 已采纳

    语法都错了,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;
            }
    
    点赞 评论
  • 万里淘金 2015-11-03 06:19

    去检查jquery语法

    点赞 评论

相关推荐 更多相似问题