跪求:检验注册用户名代码

来源:百度知道 编辑:UC知道 时间:2024/06/22 03:05:42
在一些论坛(PHP网页)就看到这样一点情况:
在注册时,在用户名输入后,去填登录密码时,用户名那栏后面出现一个绿色的√图标.我知道这是在检验我输入的用户名是不是有人用了!!

现在我想要的就是这么个代码(ASP格式的更好!),有哪位大大知道的话请告诉我,谢谢哈!!!!

前几天找到的:
<script language="javascript">
function checkName()
{
var NameStr=document.all.txtName.value
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST", "test.asp?uName="+NameStr, false);
xmlhttp.send();
if(xmlhttp.ResponseText==1)
alert("用户名已经存在");
else
alert("可以使用!");
}
}
</script>
用 户 名:<input type="text" id="txtName" name="txtName">
<input type="button" value="检测用户名" onclick="checkName()">

test.asp

<!--#include file="conn.asp" -->
<%
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from [users] where username='"&request("uName")&"'"
rs.Open sql,conn,1,1
if rs.EOF and rs.BOF then
response.