求大神们帮忙啊!!!!!!!!!!!1

yshh12345 2013-11-07 12:22:38
求大神们帮忙,不晓得为什么用过dreamwave之后 用户名有效性验证和验证码验证的那段js就没效果了,然后点击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>



...全文
148 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hch126163 2013-11-07
  • 打赏
  • 举报
回复
用浏览器 开发人员工具,很容易找到问题所在
conanhhy 2013-11-07
  • 打赏
  • 举报
回复

<%@ 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>
代码中CODE是什么?建议$user_name和$user_pwd的声明前加上var。还有createCode()方法也没有。 从目前LZ提供代码来看,除了}以外,似乎没有其他的问题。
似梦飞花 2013-11-07
  • 打赏
  • 举报
回复
<!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("验证码输入错误!"); return false; } else if($user_name==''){ alert("用户名不能为空"); return false; }else if($user_pwd==''){ alert("密码不能为空"); return false; } return true; } </script> <body> <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"> </font> </td> </tr> <tr> <td> 密码: </td> <td> <input type="password" name="password" id="password" title="请输入密码" maxlength="20" /> <font color="ff0000"> </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> 多出来一些大括号 code未定义 createCode()方法没贴出来
liuxinran819 2013-11-07
  • 打赏
  • 举报
回复
定义function checkform()的时候 大括号的数量不对 那段js都没执行成功~~~

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧