Ajax detects whether mailboxes are registered

Source: Internet
Author: User
  code is as follows copy code

If (document.register.email.value.charAt (0) = = "." | |        
         Document.register.email.value.charAt (0) = = "@" | |       
         Document.register.email.value.indexOf (' @ ', 0) = = 1 | |
         document.register.email.value.indexOf ('. ', 0) = = 1 | |
         document.register.email.value.lastIndexOf ("@") = = document.register.email.value.length-1 | |
         document.register.email.value.lastIndexOf (".") ==document.register.email.value.length-1)
     {
      alert ( "E-mail format is not correct!" ");
      Document.register.email.focus ();
      return false;
     }

SendRequest ("checkemail.asp?email=" + document.register.email.value);
if (return_str== "0") {
Alert ("This mailbox already exists, please choose another");
Document.register.email.focus ();
Document.register.email.select ();
return False
}

Ajax processing

The code is as follows Copy Code

var return_str= ""


XMLHTTP = new ActiveXObject ("Msxml2.xmlhttp");
function SendRequest (SNDSTR)
{
var xmldom = new ActiveXObject ("Msxml2.domdocument");
Xmlhttp.open ("Get", Sndstr, false);
Xmlhttp.onreadystatechange = Sendrequest_check;
xmlHTTP. Send (XMLDOM);
}
//--------------------------------------------------------
function Sendrequest_check ()
{
var state = Xmlhttp.readystate;

var xmldom = new ActiveXObject ("Msxml2.domdocument");

if (state = = 4)
{
XMLDOM.loadXML (Xmlhttp.responseXML.xml);
Return_str = XmlDom.documentElement.selectSingleNode ("//objxml"). Text;
}
}

checkemail.asp file you only have to accept the user's information, in the database to check the KO.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.