| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 533 人关注过本帖
标题:求大神帮忙看看错在哪里
只看楼主 加入收藏
yshh
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-11-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求大神帮忙看看错在哪里
不晓得为什么,自从拿dreamwave 调整过页面 我的用户名有效性验证和验证码验证的function就无效了,点了submit就会直接通过servlet跳转,求大神帮忙!


程序代码:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">

        <title>用户登录</title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
        <script language="javascript" src="javascript/code/code.js"></script>
        <link rel="stylesheet" type="text/css" href="javascript/code/code.css">
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <style type="text/css">
<!--
body {
    background-image: url(image/loginindex.jpg);
}

#Layer1 {
    position: absolute;
    width: 414px;
    height: 188px;
    z-index: 1;
    left: 164px;
    top: 452px;
}
-->
</style>
    </head>
    <EMBED src="/petshop/music/karo.mp3" autostart="true" loop="true"
        hidden="true"></EMBED>
    <script type="text/javascript">
        function checkform(){
             $user_name=document.getElementById("username").value;
             $user_pwd=document.getElementById("password").value;
             var inputCode = document.getElementById("input1").value.toUpperCase();
            var codeToUp = code.toUpperCase();
            if (inputCode.length <= 0) {
                alert("请输入验证码!");
                return false;
            } else if (inputCode != codeToUp) {
            alert("验证码输入错误!");
            createCode();
            return false;
            } else if($user_name==''){
             alert("用户名不能为空");
             return false;
             }else if($user_pwd=='')
             {
              alert("密码不能为空");
              return false;
             }
         }
         return true;
    }
}
</script>

    <body onLoad="createCode();">
        <form action="/petshop/servlet/loginservlet" method="get" name="form1"
            id="form1" onSubmit="return checkform()">
            <div id="Layer1">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="87">
                            用户名:
                        </td>
                        <td width="325">
                            <input type="text" name="username" id="username"
                                title="请输入用户名,6~18个字符,可使用字母、数字、下划线,需以字母开头" maxlength="16" />
                            <font color="ff0000"> <%
     if ((String) session.getAttribute("unerror") != null) {
         out.print((String) session.getAttribute("unerror"));
     }

 %> </font>
                        </td>
                    </tr>



                    <tr>
                        <td>
                            密码:
                        </td>
                        <td>
                            <input type="password" name="password" id="password"
                                title="请输入密码" maxlength="20" />
                            <font color="ff0000"> <%
     if ((String) session.getAttribute("pwderror") != null) {
         out.print((String) session.getAttribute("pwderror"));
     }

 %> </font>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            验证码:
                        </td>
                        <td>
                            <input name="text" type="text" id="input1" />
                            <input name="text" type="text" class="code" id="checkCode"
                                style="width: 55px" />
                            <a href="#" onClick="createCode()">看不清楚</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <input type="submit" name="button" id="button" value="登陆" />
                        </td>
                        <td>
                            <input type="reset" name="reset" id="reset" value="重置" />
                        </td>
                    </tr>
                </table>
            </div>
        </form>
    </body>
</html>

搜索更多相关主题的帖子: function 验证码 PUBLIC 用户名 import 
2013-11-07 00:09
诸葛修勤
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:11
帖 子:549
专家分:1955
注 册:2010-10-28
收藏
得分:20 
下断点 调试下
2013-11-07 01:15
快速回复:求大神帮忙看看错在哪里
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016587 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved