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

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 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据