<script language="JavaScript">
<!--
function check_User() {
var xmlHttp = false;
try {xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {try {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e2) {xmlHttp = false;}}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {xmlHttp = new XMLHttpRequest();}
if (document.form1.User.value!="") {
var User = document.form1.User.value;
xmlHttp.open("GET","reg_detectname.asp?a=b&name="+escape(User),false);
xmlHttp.send(null);
document.getElementById('a1').innerHTML = xmlHttp.responseText;
document.form1.submit.disabled = false;
} else {
document.getElementById('a1').innerHTML = "<font color=red>名字不能为空</font>";
document.a1.submit.disabled = true;
return true;
}
}
//-->
</script>
<form name="form1" action="Reg_save.asp" method="POST">
<input name="User" type="text" onkeyup="check_User();" /> <span id="a1"></span>
</form>
reg_detectname.asp
<!--#include file="conn.asp"-->
<%
if request("a")="b" then
User=request("name")
set rs=server.createobject("adodb.recordset")
rs.open "select * from UserMain where User='"&User&"'",conn,1,1
if rs.bof and rs.eof then
response.write "<font color=green>可以注册 !</font>"
else
response.write "<font color=red>不可以注册 !</font>"
end if
rs.close
set rs=nothing
end if
%>