Optimize the user Checkup function
Front page:
<script type= "Text/javascript" >
function Createxhl () {
if (window. XMLHttpRequest)
return new XMLHttpRequest;
else if (window. ActiveXObject)
return new ActiveXObject ("Microsoft.XMLHTTP");
}
var xhr = "";
function Checkmail () {
var mail = document.getElementById ("Txtemail"). Value;
var url = "Ajaxmail.ashx?mail=" + mail;
Create a Xhr object
XHR = Createxhl ();
Setting the callback function
Xhr.onreadystatechange = Readdo;
Initializing the XHR object
Xhr.open ("Get", url, True);
Xhr.setrequestheader ("Content-type", "application/x-www-form-urlencoded");
Send
Xhr.send (NULL);
}
function Readdo () {
if (xhr.readystate = = 4 && xhr.status = = 200) {
var result = Xhr.responsetext;
var msg = document.getElementById ("Ltmail");
if (result = = "true")
msg.innerhtml = "The mailbox already exists!" ";
Else
msg.innerhtml = "Mailbox can be used!" ";
}
}
</script>
<body>
<form id= "Form1" runat= "Server" >
<div>
<p> Mail Box: </p>
<input id= "Txtemail" type= "text" class= "input" onchange= "Checkmail ()"/><br/>
<asp:label id= "Ltmail" runat= "server" text= "Please enter a common mailbox" ></asp:Label>
</div>
</form>
</body>