﻿// JavaScript Document
var xmlhttp
try{
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(E)
{
try{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
xmlhttp=new XMLHttpRequest();
}
}

function checkuser(username){
	
    if(username.length<4){      
    document.getElementById("showArea").innerHTML ="<font color=red>用户名不得少于4个字符</span>";
    return false;
    }	
    else
	{
	if(!/^([\u4e00-\u9fa5]|[A-Za-z0-9_])*$/.test(username)) {
	document.getElementById("showArea").innerHTML ="<font color=red>用户名应为中文、英文、数字或下划线</span>";							 
	  return false; 
	} 
	
	else
	{
      if(username!=""){
          var oDoc = new ActiveXObject("MSXML2.DOMDocument"); 
          xmlhttp.open("POST", "../checkuser.asp?username="+username, true); 
          xmlhttp.onreadystatechange=checking;
          xmlhttp.send(""); 
         }
    
    }
	}
}

function checking()
{

if(xmlhttp.readystate<4){
 document.getElementById("showArea").innerHTML ="&nbsp;正在查询……";
 
}
if(xmlhttp.readyState==4){
	
  if(xmlhttp.status == 200)
      {
            result = xmlhttp.responseText; 
			//alert(result);
            if(parseInt(result)==0){
             document.getElementById("showArea").style.display='';
            document.getElementById("showArea").innerHTML ="<font color=green>恭喜您!该用户名可以注册</span>";
            //document.getElementById("chk").value="0";
            }
            else if(parseInt(result)>0){
             document.getElementById("showArea").style.display='';
            document.getElementById("showArea").innerHTML ="<font color=red>此用户名已经被注册,请重新选择</span>";
            //document.getElementById("chk").value="1";
            }
           }
       else
       {
        
          document.getElementById("showArea").innerHTML = "正在查询数据……";   
        }
}
}


function checkpwd()
{
	if (form1.userPwd.value.length<6 || form1.userPwd.value.length>16)
   {
   	document.getElementById("showArea3").innerHTML ="<font color=red>请输入6-16位的密码</span>";
    }
  else
  {
	 document.getElementById("showArea3").innerHTML ="<font color=green>输入正确</span>";
  }
}

function checkpwd2()
{
	if (form1.userPwd.value!=form1.userPwd2.value)
   {
  	 document.getElementById("showArea4").innerHTML ="<font color=red>两次密码输入不一致</span>";
   }
   else
   {	
		if(form1.userPwd2.value.length<6)
		{  document.getElementById("showArea4").innerHTML ="<font color=red>请输入6-16位的密码</span>";
			 form1.userPwd2.focus();
		}
		else
		 document.getElementById("showArea4").innerHTML ="<font color=green>输入正确</span>";
	}
}