这个例子是验证163邮箱.
<
title
>
163邮箱验证
</
title
>

<
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
>

































































