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

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条回答 默认 最新

  • Go 旅城通票 2015-11-03 03:12
    关注

    语法都错了,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;
            }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch