﻿var xmlHttpReq;   
//创建XMLHTTP对象     
function createXMLHttpRequest()
{     
    if(window.ActiveXObject)
    {    // IE，//如果浏览器支持window.ActiveXObject对象  
        xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");     
        var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];  
        try 
        {  
            xmlHttpReq= new ActiveXObject("Msxml2.XMLHTTP");  
        }   
        catch (e)
        {  
            try
            {  
                xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");  
            }   
            catch (e) {}  
        }
    }
    else if(window.XMLHttpRequest)
    {    // Mozilla, Safari, ...  
        xmlHttpReq = new XMLHttpRequest();     
    }     
}   

function getXmlSend()
{  
    createXMLHttpRequest(); 
    var regname=document.getElementsByName("regname"); 
    var te=regname[0].value;
        
    var menotice=document.getElementById("menotice");
    if (te.length < 2)
    {
        menotice.innerHTML="用户名长度不能小于 2 位!";
        return false;
    }
    
    var url= "CheckUserNameExists.aspx?UserName="+te;
    
    xmlHttpReq.open("GET",url,true);  
    
    //xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');   
    xmlHttpReq.onreadystatechange = showResultNews;  //异步调用showResult方法  
    xmlHttpReq.send(null); // 开始发起浏览请求, Mozilla 必须加 null 
    
}  
function getXmlSend1()
{  
    createXMLHttpRequest(); 
    var regname=document.getElementsByName("regname1"); 
    var te=regname[0].value;
        
    var menotice=document.getElementById("menotice1");
    if (te.length < 2)
    {
        menotice.innerHTML="用户名长度不能小于 2 位!";
        return false;
    }
    
    var url= "CheckUserNameExists.aspx?UserName="+te;
    
    xmlHttpReq.open("GET",url,true);  
    
    //xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');   
    xmlHttpReq.onreadystatechange = showResultNews1;  //异步调用showResult方法  
    xmlHttpReq.send(null); // 开始发起浏览请求, Mozilla 必须加 null 
    
}  


function showResultNews()
{      
    if(xmlHttpReq.readyState == 4)
    {        
        if(xmlHttpReq.status == 200)
        {              
            var menotice=document.getElementById("menotice");
            if (xmlHttpReq.responseText.substr(0,6)=="exists")
            {
                menotice.innerHTML="该用户名已存在，请重新填写用户名!";
            }
            else
            {
                menotice.innerHTML="此用户名可以注册!";
            }
        }  
    }               
}
function showResultNews1()
{      
    if(xmlHttpReq.readyState == 4)
    {        
        if(xmlHttpReq.status == 200)
        {              
            var menotice=document.getElementById("menotice1");
            if (xmlHttpReq.responseText.substr(0,6)=="exists")
            {
                menotice.innerHTML="该用户名已存在，请重新填写用户名!";
            }
            else
            {
                menotice.innerHTML="此用户名可以注册!";
            }
        }  
    }               
}