无法验证用户名

mysite365 2008-04-11 03:50:21
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn/my_conn.asp"-->
<!--#include file="str_filter.asp"-->
<!--#include file="md5.asp"-->
<% function reg_check()
username=str_filter(request.Form("username"))
userpassword=md5(str_filter(request.Form("userpassword")))
email=str_filter(request.Form("email"))
question=str_filter(request.Form("question"))
answer=str_filter(request.Form("answer"))
turename=str_filter(request.Form("turename"))
scope=str_filter(request.Form("scope"))
id_card=str_filter(request.Form("id_card"))
sex=str_filter(request.Form("sex"))
address=str_filter(request.Form("address"))
zip=str_filter(request.Form("zip"))
phone=str_filter(request.Form("phone"))
qq=str_filter(request.Form("qq"))
if username<>""and userpassword<>""and question<>"" and answer<>"" and turename<>"" and id_card<>"" and sex<>"" and address<>"" and phone<>""and scope<>"" then
set rs=server.createobject("adodb.recordset")
rs.open "select * [bout_user] where turename='"&turename&"'",conn,1,3
if not rs.eof then
response.Write("<script language='javascript'>arert('此用户已存在,请重新输入!');</script>")
else
rs.addnew
rs("username")=username
rs("userpassword")=userpassword
rs("email")=email
rs("question")=question
rs("answer")=answer
rs("turename")=turename
rs("id_card")=id_card
rs("sex")=sex
rs("address")=address
rs("zip")=zip
rs("scope")=scope
rs("phone")=phone
rs("qq")=qq
rs.update
rs.close
set rs=nothing

session("username")=username
session("turename")=turename
session("password")=userpassword
response.Write("<script language='javascript'>arert('恭喜你会员注册成功!');window.location.href='../index.asp';</script>")
end if
else
response.Write("<script language='javascript'>arert('请将信息填写完整!');</script>")
end if
end function
%>
<%
if not isempty (request.Form("check")) then
if request.Form("username")<>""then
set rs=server.createobject("adodb.recordset")
rs.open "select username from [bout_user] where username='"&str_filter(request.Form("username"))&"'",conn,1,3
if rs.eof then
response.Write("<script language='javascript'>arert('此用户可以使用!');</script>")
else
response.Write("<script language='javascript'>arert('此用户已存在,请重新输入!');</script>")
end if
rs.close
set rs=nothing
else
response.Write("<script language='javascript'>arert('请输入用户名!');</script>")
end if
end if

if not isempty (request.Form("sumbit")) then
call reg_check()
end if

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="css/mycss.css" rel="stylesheet" type="text/css">
<title>用户注册</title>
<style type="text/css">
<!--
.STYLE2 {
color: #666666;
font-weight: bold;
font-size: 11pt;
font-family: "宋体";
}
.STYLE4 {color: #019867; font-weight: bold; font-size: 11pt; font-family: "宋体"; }
.STYLE5 {color: #FF0000}
-->
</style>
<script language="JavaScript">
<!--
function IsDigit()
{
return ((event.keyCode >= 48) && (event.keyCode <= 57));
}

function check()
{
if(checkspace(form1.username.value)) {
form1.username.focus();
alert("对不起,请填写用户名!");
return false;
}
if(checkspace(form1.userpassword.value) || form1.userpassword.value.length < 6 || form1.userpassword.value.length >20) {
form1.userpassword.focus();
alert("密码长度不能不能为空,在6位到20位之间,请重新输入!");
return false;
}
if(form1.userpassword.value != form1.userpassword1.value) {
form1.userpassword.focus();
form1.userpassword.value = '';
form1.userpassword1.value = '';
alert("两次输入的密码不同,请重新输入!");
return false;
}

if(form1.email.value.length!=0)
{
if (form1.email.value.charAt(0)=="." ||
form1.email.value.charAt(0)=="@"||
form1.email.value.indexOf('@', 0) == -1 ||
form1.email.value.indexOf('.', 0) == -1 ||
form1.email.value.lastIndexOf("@")==form1.email.value.length-1 ||
form1.email.value.lastIndexOf(".")==form1.email.value.length-1)
{
alert("Email地址格式不正确!");
form1.email.focus();
return false;
}
}
else
{
alert("Email不能为空!");
form1.email.focus();
return false;
}
if(checkspace(form1.quesion.value)) {
form1.quesion.focus();
alert("对不起,请填写密码提问!");
return false;
}
if(checkspace(form1.answer.value)) {
form1.answer.focus();
alert("对不起,请填写密码提问的答案!");
return false;
}
if(checkspace(form1.turename.value)) {
form1.turename.focus();
alert("对不起,请填写真实姓名!");
return false;
}
if(checkspace(form1.adress.value)) {
form1.adress.focus();
alert("对不起,请填写通讯地址!");
return false;
}

}
if(checkspace(form1.zip.value)) {
form1.zip.focus();
alert("对不起,请填写邮编!");
return false;
}
if(form1.zip.value.length!=6) {
form1.zip.focus();
alert("对不起,请正确填写邮编!");
return false;
}
if(checkspace(form1.phone.value)) {
form1.phone.focus();
alert("对不起,请留下您的联系电话!");
return false;
}

}
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
//-->
</script>
</head>

<body>
<!--#include file="top.asp"-->
<table width="777" height="430" cellspacing="0" cellpadding="0" style="border:1.5px #3AB928
solid;border-width:0 1 1 1; margin-top:6px;" align="center">

<tr>
<td align="left">

<table width="98%" border="0">
<tr>
<td height="21"> </td>
<td width="165" align="right"><em><font color="#ff0000">*号为必填项,请认真填写</font></em></td>
</tr>
</table>

<form id="form1" name="form1" method="post" action="">

<table width="98%" cellpadding="4" cellspacing="0" style="border:4px solid #EAFCE6;">
<tr>
<td height="23" align="left"><span class="STYLE4">用户名和密码:</span></td>
</tr>
<tr bgcolor="#EAFCE6">
<td height="29" bgcolor="#EAFCE6" align="left"><font color="#CC0000">*</font> 用 户 名:
<input type="text" name="username" size="18" maxlength="20" onblur="check()">
<input type="button" name="check" value="检测用户" tabindex="50">

支持中文,不支持特殊符号如:*%#!-&%$</td>
</tr>
<tr>
<td height="30">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="180"><font color="#CC0000">*</font> 密  码:
<input type="userpassword" name="userpassword" size="12" maxlength="12" onblur="return check()"></td>
<td>请使用5--12位,不支持特殊符号如:*%#!-&%$</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#EAFCE6">
<td height="26">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="180"><font color="#CC0000">*</font> 确认密码:
<input name="userpassword1" type="password" size="12" maxlength="12" onblur="return check()"></td>
<td>请再输入一遍您上面填写的密码。</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="318"><font color="#CC0000">*</font> 电子邮箱:
<input type="text" name="email" size="25" maxlength="50" onblur="return check()"></td>
<td width="246"></td>
</tr>
</table>
...全文
135 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
guaidian2008 2008-04-15
  • 打赏
  • 举报
回复
代码太长了,没时间一点一点看。
我想主要可能是JS有问题,或者是FORM有重名之类的。
md5e 2008-04-11
  • 打赏
  • 举报
回复
<input name=Submit type=button id="Submit" value="提交表单" onClick="check()">
建议把提交改成按钮进行调试
myvicy 2008-04-11
  • 打赏
  • 举报
回复
教你如何解决:
先备份,然后把不能执行的代码都删除了。
然后找到最小的正确代码集合,然后就一个一个往最小集合里加代码,加一个测试一个,没有错误了再加其他的,遇到错误就解决它,这样就能解决问题了。
否则如果错误太多,自己有比较手生,就很麻烦了。
mysite365 2008-04-11
  • 打赏
  • 举报
回复
内容意思很简单,主要重复代码太多。。。
Atai-Lu 2008-04-11
  • 打赏
  • 举报
回复
估计是js代码有错误
最可能的是某个表单值没正确获取
zym369012 2008-04-11
  • 打赏
  • 举报
回复
代码太多,估计大家都没有时间细看..
mysite365 2008-04-11
  • 打赏
  • 举报
回复
</td>
</tr>
<tr bgcolor="#EAFCE6">
<td height="31">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="316"><font color="#CC0000">*</font> 我的问题:
<input name="question" type="text" size="25" maxlength="50" onblur="return check()"></td>
<td width="248"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="320"><font color="#CC0000">*</font> 问题答案:
<input type="text" name="answer" size="25" maxlength="50" onblur="return check()"></td>
<td width="244"></td>
</tr>
</table>
</td>
</tr>

</table>

<table width="98%" height="10" border="0">
<tr>
<td></td>
</tr>
</table>

<table width="98%" cellpadding="4" cellspacing="0" style="border:4px solid #F3F3F3;">
<tr bgcolor="#EAFCE6">
<td width="556" height="28"><span class="STYLE2">用户详细资料: </span>     </td>
</tr>
<tr>
<td height="2" bgcolor="#F3F3F3"></td>
</tr>
<tr>
<td height="26" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="43%"><font color="#CC0000">*</font> 真实姓名:
<input type="text" name="turename" size="17" maxlength="30" onblur="return check()"></td>
<td width="57%">请不要使用假名,我们会进行真实核对。</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="30" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr >
<td width="52%"><font color="#CC0000">* </font>所属范围:
<select name="scope"onchange="chg(this.value);"> 'onchange="return changeClass();"
<option value="" selected>==请选择所属范围==</option>
<option value="0">社会人士</option>
<option value="1">海洋大学</option>
<option value="2">青岛理工大学</option>
</select>
</td>
<td width="48%"></td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="28" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="43%"><font color="#CC0000">*</font> 身份证号:
<input type="text" name="id_card" size="17" maxlength="25" onKeyPress="event.returnValue=IsDigit();"onblur="return check()" ></td>
<td width="57%"> </td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="25" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" align="right"> 性别:</td>
<td width="90%"><input type=radio name=sex id=Select1 value=0 checked>男 <input type=radio name=sex id=Select1 value=1>女</td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="25" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="43%"><font color="#CC0000">*</font> 通讯地址:
<input type="text" name="adress" size="17" maxlength="25" onblur="return check()"></td>
<td width="57%"> </td>
</tr>

</table>
</td>
</tr>
<tr>
<td height="26" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" align="right">邮编:</td>
<td width="90%"><input type="text" name="zip" size="17" maxlength="25" onblur="return check()" onKeyPress="event.returnValue=IsDigit();"></td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="28" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="43%"><font color="#CC0000">*</font> 联系电话:
<input type="text" name="phone" size="17" maxlength="25" onblur="return check()" onKeyPress="event.returnValue=IsDigit();"></td>
<td width="57%"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="26" >
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" align="center">Q Q :</td>
<td width="90%"><input type="text" name="qq" size="17" maxlength="25" onblur="return check()" onkeypress="event.returnValue=IsDigit();" /></td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="6" bgcolor="#F3F3F3"></td>
</tr>


</table>

<table width="98%" height="10" border="0">
<tr>
<td></td>
</tr>
</table>
<table width="98%" border="0" cellpadding="4" cellspacing="0" style="border:4px solid; border-color:#F3F3F3;">
<tr >
<td height="30"><FONT COLOR="#CC0000">*</FONT> 验 证 码:
<input type="text" name="authcode" size="10" value="<% If GetCode=9999 Then Response.Write "9999"%>">
请输入右边的附加码:<img src=GetCode.asp>
</td>
</tr>
<tr >
<td height="31" >您是否同意<a href="http://www.tianzhentea.com" target=_blank>《青岛茗品茶业有限公司服务条款》</a></td>
</tr>
<tr >
<td height="28">
<div align="center">
<input type="radio" name="argee" value="1" checked>
同意  
<input type="radio" name="argee" value="0">
不同意</div></td>
</tr>
<tr align="center">
<td>
<input type="submit" border="0" width="91" height="27" value="提交表单">  
<input type="reset"border="0" width="91" height="27" value="重新填写"> </td>
</tr>
</table>
</form>


</td>
</tr>
</table>
<!--#include file="copyright.asp"-->
</body>
</html>


无法验证用户名,并且也不能onkeypress="event.returnValue=IsDigit();" 限制其输入,还有点击提交表单也不进行验证。。总之,事件代码都没起作用。。。。。。。。。。。。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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