52,797
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<title>用户名检测</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript">
/* var httpRequest;
//创建XMLHttpRequest对象
function createXMLHttpRequest() {
/* if(window.ActiveXObject)
httpRequest = new ActiveXObject("MSXML2.XMLHTTP.6.0");
else if(window.XmlHttpRequest)
httpRequest = new XmlHttpRequest();
else
try{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");}
catch
{
alert("对不起,浏览器不支持该对象 xmlhttprequest");
}
}*/
var httpRequest;
//创建XMLHttpRequest对象
function createXMLHttpRequest() {
if(window.XMLHttpRequest) { //非IE浏览器
httpRequest = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE浏览器
httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}
}
//发送请求函数
function sendRequest(url) {
createXMLHttpRequest();
httpRequest.open("GET",url,true);
httpRequest.onreadystatechange = processResponse;//指定响应函数
httpRequest.send(null); // 发送请求
}
// 处理返回信息函数
function processResponse() {
if (httpRequest.readyState == 4) { // 判断对象状态
if (httpRequest.status == 200) { // 信息已经成功返回,开始处理信息
var obj=document.getElementById("res");
var Result=httpRequest.responseText;
obj.innerHTML=Result;
//window.alert("数据返回成功!");
window.alert(obj.innerHTML);
} else { //页面不正常
window.alert("请求页面异常");
}
}
}
// 用户名验证函数
function userCheck() {
var username = document.getElementById("mobile").value;
if(userName =="") {
window.alert("用户名不能为空");
document.myform.mobile.focus();
return false;
}
else {
var url="Login.asp?userName="+ userName;
sendRequest(url);
}
}
</script>
</head>
<body>
<form name=form1 id="myform" method=post action="Login.asp?yanzi()" onsubmit="checkPhone(mobile.value);" >
用户名:<input type="text" name="mobile" id="mobile">
<input type=Button name= "MemberButton " value= "提交" onClick= "userCheck();" id="Button" /><br>
<div id="res"></div>
</form>
</body>
</html>
<!--#include file="sub/conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<%
'Response.ContentType = "text/html"
'Response.Charset = "utf-8"
dim username,sql
username=request.querystring("username")
username="999"
set rs=server.createobject("adodb.recordset")
sql="select id username from love_main where username='"&username&"'"
rs.open sql,conn,1,3
if rs.bof or rs.eof then
response.write ("恭喜您!用户名可以使用。")
else
response.write ("用户名已被占用,请用别的名称")
end if
rs.close
set rs=nothing
%>
</body>
</html>