注册 登录
编程论坛 ASP技术论坛

用户检测问题

longxuanxuan 发布于 2010-04-26 20:00, 484 次点击
function jcyh()
{
var NameStr=document.zhuce.mingcheng.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","regjc.asp?uName="+NameStr, false);

xmlhttp.send();
if(xmlhttp.ResponseText==1)
alert("用户名已经存在");
else
alert("可以使用!");
}

这是处理页面  
<!--#include file="lianku.asp"-->
<%
sql="select*from zhuce1 where mingcheng='"&request("uName")&"'"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
   response.write 0
else
response.write 1
end if
rs.close
set rs=nothing
%>


能帮我看看是哪里出错了吗
2 回复
#2
yms1232010-04-26 21:44
function jcyh()
{
var NameStr=document.zhuce.mingcheng.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","regjc.asp?uName="+NameStr, false);

xmlhttp.send();
if(xmlhttp.ResponseText=="1")//或者if(parseInt(xmlhttp.ResponseText)==1)
alert("用户名已经存在");
else
alert("可以使用!");
}
因为哪里得到的是文本值,文本值无法直接与数字比较。
#3
longxuanxuan2010-04-27 09:35
谢谢了!
1