<script>
var xmlhttp=false;
function GetXMLHTTP()
{
try
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
try
{
xmlhttp=new ActiveXObject("MSxml2.XMLHTTP.3.0");
}
catch(e)
{
xmlhttp=false;
}
}
return xmlhttp;
}
function validate(username)
{
GetXMLHTTP();
var url="http://reg.163.com/reg/reg0.jsp?username="+username;
xmlhttp.open("post",url,true);
xmlhttp.setRequestHeader("Content-Type","utf-8");
xmlhttp.onreadystatechange=callbackvalidate;
xmlhttp.send();
}
function callbackvalidate()
{
if(xmlhttp.readyState==4)
{
//如果用戶名存在表示這是一個正確的E-mail
if(xmlhttp.responseText.indexOf("用戶名已經存在")>0)
{
document.getElementById("divinfo").innerHTML="該郵箱可以使用";
}
else
{
document.getElementById("divinfo").innerHTML="該郵箱不可以使用";
}
}
}
</script>
<body>
<INPUT TYPE="text" id="txt" NAME="txt">
<INPUT TYPE="button" VALUE=" GO " ONCLICK="validate(txt.value)"
ID="Button1" NAME="Button1">
<div id="divinfo"></div>
</body>