﻿
function showAndHide(obj,types){ 
    var Layer=window.document.getElementById(obj); 
    switch(types){ 
      case "show": 
        Layer.style.display="block"; 
      break; 
      case "hide": 
        Layer.style.display="none"; 
    } 
} 
//function getValue(obj,str){ 
//    var input=window.document.getElementById(obj); 
//    input.value=str; 
//} 

//主表单验证
 function regCheck()
 {
    var vEmail=document.getElementById("<%=txtEmail.ClientID %>");
    
    if(vEmail.value=="")
    {
        document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;请输入Email地址";
        document.getElementById("List2").style.color="#FF1800";
        showAndHide("List2","show");
        showAndHide("List1","hide");
        showAndHide("List3","hide");
        vEmail.focus();
        return false;
    }
    if(CheckEmail(vEmail.value)==false)
    {
        document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;请输入合法的Email地址";
        document.getElementById("List2").style.color="#FF1800";
        showAndHide("List2","show");
        showAndHide("List1","hide");
        showAndHide("List3","hide");
        vEmail.focus();
        return false;
    }
    if(Yidianda.Web.User.Register.EmailCheck(vEmail.value).value=="0")
    {
        document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;这个Email已经有人使用了";
        document.getElementById("List2").style.color="#FF1800";
        showAndHide("List2","show");
        showAndHide("List1","hide");
        showAndHide("List3","hide");
        vEmail.focus();
        return false;
    }
    showAndHide("List2","hide");
    showAndHide("List1","hide");
    showAndHide("List3","show");
    
    
    var vUsername=document.getElementById("<%=txtUsername.ClientID %>");
    
    if(vUsername.value=="")
    {
        document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;请输入用户名";
        document.getElementById("List5").style.color="#FF1800";
        showAndHide("List5","show");
        showAndHide("List4","hide");
        showAndHide("List6","hide");
        vUsername.focus();
        return false;
    }
    if(Yidianda.Web.User.Register.UsernameCheck(vUsername.value).value=="0")
    {
        document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;用户名已存在";
        document.getElementById("List5").style.color="#FF1800";
        showAndHide("List5","show");
        showAndHide("List4","hide");
        showAndHide("List6","hide");
        vUsername.focus();
        return false;
    }
    if(vUsername.value.length>15)
    {
        document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;用户名不能大于15位";
        document.getElementById("List5").style.color="#FF1800";
        showAndHide("List5","show");
        showAndHide("List4","hide");
        showAndHide("List6","hide");
        vUsername.focus();
        return false;
    }
    if(vUsername.value.length<2)
    {
        document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;用户名不能小于2位";
        document.getElementById("List5").style.color="#FF1800";
        showAndHide("List5","show");
        showAndHide("List4","hide");
        showAndHide("List6","hide");
        vUsername.focus();
        return false;
    }
    showAndHide("List5","hide");
    showAndHide("List4","hide");
    showAndHide("List6","show");

    
    var vPassword=document.getElementById("<%=txtPassword.ClientID %>");
    
    if(vPassword.value=="")
    {
        document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;请输入密码";
        document.getElementById("List8").style.color="#FF1800";
        showAndHide("List8","show");
        showAndHide("List7","hide");
        showAndHide("List9","hide");
        vPassword.focus();
        return false;
    }
    if(vPassword.value.length>20)
    {
        document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;密码不能大于20位";
        document.getElementById("List8").style.color="#FF1800";
        showAndHide("List8","show");
        showAndHide("List7","hide");
        showAndHide("List9","hide");
        vPassword.focus();
        return false;
    }
    if(vPassword.value.length<6)
    {
        document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;密码不能小于6位";
        document.getElementById("List8").style.color="#FF1800";
        showAndHide("List8","show");
        showAndHide("List7","hide");
        showAndHide("List9","hide");
        vPassword.focus();
        return false;
    }
    showAndHide("List8","hide");
    showAndHide("List7","hide");
    showAndHide("List9","show");

    
    var vPassword2=document.getElementById("<%=txtPassword2.ClientID %>");
    
    if(vPassword2.value=="")
    {
        document.getElementById("List11").innerHTML="&nbsp;&nbsp;&nbsp;请输入确认密码";
        document.getElementById("List11").style.color="#FF1800";
        showAndHide("List11","show");
        showAndHide("List10","hide");
        showAndHide("List12","hide");
        vPassword2.focus();
        return false;
    }
    if(vPassword2.value!=vPassword.value)
    {
        document.getElementById("List11").innerHTML="&nbsp;&nbsp;&nbsp;两次输入密码不一致";
        document.getElementById("List11").style.color="#FF1800";
        showAndHide("List11","show");
        showAndHide("List10","hide");
        showAndHide("List12","hide");
        vPassword2.focus();
        return false;
    }

    showAndHide("List11","hide");
    showAndHide("List10","hide");
    showAndHide("List12","show");
    return true;
 }
 
       //Email格式验证正则表达式
       function CheckEmail( str )
       {
	       var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	       return Check( reg, str );
       }
        function Check( reg, str )
       {
	          if( reg.test( str ) )
	          {
		         return true;
	          }
	      return false;
       }
       
       //Email焦点离开验证
       function EmailOut()
       {
         showAndHide("List1","hide");
         var vEmail=document.getElementById("<%=txtEmail.ClientID %>");
         if(vEmail.value=="")
         {
            document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;请输入Email地址";
            document.getElementById("List2").style.color="#FF1800";
            showAndHide("List2","show");
            showAndHide("List1","hide");
            showAndHide("List3","hide");
            return false;
         }
         if(CheckEmail(vEmail.value)==false)
         {
            document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;请输入正确的Email地址";
            document.getElementById("List2").style.color="#FF1800";
            showAndHide("List2","show");
            showAndHide("List1","hide");
            showAndHide("List3","hide");
            return false;
         }
         if(Yidianda.Web.User.Register.EmailCheck(vEmail.value).value=="0")
         {
            document.getElementById("List2").innerHTML="&nbsp;&nbsp;&nbsp;该Email地址已存在";
            document.getElementById("List2").style.color="#FF1800";
            showAndHide("List2","show");
            showAndHide("List1","hide");
            showAndHide("List3","hide");
            return false;
         }
            showAndHide("List2","hide");
            showAndHide("List1","hide");
            showAndHide("List3","show");
         }
       
       //用户名焦点离开验证
       function UsernameOut()
       {
         showAndHide("List4","hide");
         var vUsername=document.getElementById("<%=txtUsername.ClientID %>");
    
         if(vUsername.value=="")
         {
           document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;请输入用户名";
           document.getElementById("List5").style.color="#FF1800";
           showAndHide("List5","show");
           showAndHide("List4","hide");
           showAndHide("List6","hide");
           return false;
         }
         if(Yidianda.Web.User.Register.UsernameCheck(vUsername.value).value=="0")
         {
           document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;该用户已存在";
           document.getElementById("List5").style.color="#FF1800";
           showAndHide("List5","show");
           showAndHide("List4","hide");
           showAndHide("List6","hide");
           return false;
         }
         if(vUsername.value.length>15)
         { 

           document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;用户名不能大于15位";
           document.getElementById("List5").style.color="#FF1800";
           showAndHide("List5","show");
           showAndHide("List4","hide");
           showAndHide("List6","hide");
           return false;
         }
         if(vUsername.value.length<2)
         {

           document.getElementById("List5").innerHTML="&nbsp;&nbsp;&nbsp;用户名不能小于2位";
           document.getElementById("List5").style.color="#FF1800";
           showAndHide("List5","show");
           showAndHide("List4","hide");
           showAndHide("List6","hide");
           return false;
         
         }
           showAndHide("List6","show");
           showAndHide("List4","hide");
           showAndHide("List5","hide");
       }
       
       //密码焦点离开验证
       function Password1Out()
       {
           var vPassword1=document.getElementById("<%=txtPassword.ClientID %>");
           if(vPassword1.value=="")
           {
             document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;请输入密码";
             document.getElementById("List8").style.color="#FF1800";
             showAndHide("List8","show");
             showAndHide("List7","hide");
             showAndHide("List9","hide");
             return false;
           }
           if(vPassword1.value.length>20)
           {
             document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;密码不能大于20位";
             document.getElementById("List8").style.color="#FF1800";
             showAndHide("List8","show");
             showAndHide("List7","hide");
             showAndHide("List9","hide");
             return false;
           }
           if(vPassword1.value.length<6)
           {
             document.getElementById("List8").innerHTML="&nbsp;&nbsp;&nbsp;密码不能小于6位";
             document.getElementById("List8").style.color="#FF1800";
             showAndHide("List8","show");
             showAndHide("List7","hide");
             showAndHide("List9","hide");
             return false;
            }
            showAndHide("List8","hide");
            showAndHide("List7","hide");
            showAndHide("List9","show");
       }
       
       //确认密码焦点离开验证
       function Password2Out()
       {
          var vPassword1=document.getElementById("<%=txtPassword.ClientID %>");
          var vPassword2=document.getElementById("<%=txtPassword2.ClientID %>");
    
          if(vPassword2.value=="")
          {
            document.getElementById("List11").innerHTML="&nbsp;&nbsp;&nbsp;请输入确认密码";
            document.getElementById("List11").style.color="#FF1800";
            showAndHide("List11","show");
            showAndHide("List10","hide");
            showAndHide("List12","hide");
            return false;
           }
          if(vPassword2.value!=vPassword1.value)
          {
            document.getElementById("List11").innerHTML="&nbsp;&nbsp;&nbsp;两次输入密码不一致";
            document.getElementById("List11").style.color="#FF1800";
            showAndHide("List11","show");
            showAndHide("List10","hide");
            showAndHide("List12","hide");
            return false;
          }
          showAndHide("List11","hide");
          showAndHide("List10","hide");
          showAndHide("List12","show");
       }
       
       //表单点击提示方法
       function EmailClickShow()
       {
          showAndHide("List1","show");
          showAndHide("List2","hide");
          showAndHide("List3","hide");
       }
       function UsernameClickShow()
       {
          showAndHide("List4","show");
          showAndHide("List5","hide");
          showAndHide("List6","hide");
       }
       function Password1ClickShow()
       {
          showAndHide("List7","show");
          showAndHide("List8","hide");
          showAndHide("List9","hide");
       }
       function Password2ClickShow()
       {
          showAndHide("List10","show");
          showAndHide("List11","hide");
          showAndHide("List12","hide");
       }