<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>ajax User Registration detects if user name has been deleted </title>
<script language= "Web Effects" >
function $ (ID) {
return document.getElementById (ID);
}
function Createxmlhttp ()
{
var xmlhttp=null
try{
Xmlhttp=new XMLHttpRequest ();
}
catch (e) {
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
return (XMLHTTP);
}
function CheckUser (u_name) {
if ("==u_name)
{
$ (" Usercheck "). innerHTML =" <font color=red>x user name cannot be empty! " </font>
return
if (u_name.length<3) | | (u_name.length>12))
{
$ ("Usercheck"). innerHTML = "<font color=red>x user name is 3 to 12 characters!</font > "
return;
}
var datatosend = "U_name=" +u_name;
var xmlhttp = createxmlhttp ();
xmlhttp.open ("Post", "Usercheck.asp Tutorial", false);
xmlhttp.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send (datatosend);
var Strr=xmlhttp.responsetext;
if ("1000" ==STRR)
{
$ ("Usercheck"). innerHTML = " <font color=green>√ username "+u_name+" has not been registered, you can use! </font>
}
else if ("2002" ==STRR)
{
$ (" Usercheck "). innerHTML =" <font color=red>x user name "+u_name+" has been registered, please change user name! </font> "
}
</script>
<body>
<tr>
<TD width= "height=" bgcolor= "#ffffff" > Username:</td>
<TD height= "bgcolor=" #ffffff "><input onblur=" checkuser (this.value) "Name=" U_name "size=" >& Nbsp; <span id=usercheck style= "border:1px solid RGB (102, 102, 255); padding:2px; Background-color:rgb (221, 255, 255); > required, username 3-12 characters, can only contain 0-9,a-z,a-z or underscores </span></td>
</tr>
</body>
Usercheck.asp File Code
If Request ("username") <> "then
Response.Write ("1")
End If