﻿// JScript 文件

function isSpace()
    {
      var code = document.all.txb_code;
      var username = document.all.txb_username;
      var pwd =document.all.txb_pwd;
      var pwd_confirm = document.all.txb_pwd_confirm;
      var question = document.all.ddl_question;
      var answer = document.all.txb_answer;
      var mail = document.all.txb_mail;
      var mobile = document.all.txb_mobile;
      var telephone = document.all.txb_telephone;
      var validation_code = document.all.txb_validation_code;
      var checkRead = document.getElementById("checkRead");
     
      if(code.value.trim().length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      
      if(code.value.trim().length!=0)
      {
            var myreg = /^[0-9a-zA-Z][a-zA-Z0-9_]{1,20}$/;
            if(!myreg.test(code.value.trim()))
            {
                alert('帐号名只能由字母或数字开头，允许2-20字节，允许字母数字下划线');
                return false;
            } 
      }

      
      if(username.value.trim().length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }     
      
      if(pwd.value.length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      
      if(pwd.value.length!=0)
      {
        var myreg = /^[0-9a-zA-Z]{6,16}$/;
        if(!myreg.test(pwd.value))
            {
                alert('密码不少于6位,最多16位：只能由英文字母、阿拉伯数字构成，不能有空格，并且必须以英文字母或数字开头');
                pwd.value="";  
                pwd_confirm.value="";
                return false;
            }
      }
    
      
      if(pwd_confirm.value.length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      if(pwd.value!=pwd_confirm.value)
      {
        alert("两次输入的新密码不一致!请重新输入!");  
        pwd.value="";  
        pwd_confirm.value="";
        return   false   
      }
      
      if(question.options.value.trim().length==0 )
      {
        alert('带*为必填,请填写!');
        return false;
      }
      
      if(answer.value.trim().length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      
      if(mail.value.trim().length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      
      if(mail.value.trim().length!=0)
      {
        var myreg=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
        if(!myreg.test(mail.value.trim()))
        {
            alert('Email格式无效缺少字符@或@在处第一位!');
            return false;
        }
      }
      
       if(mobile.value.trim().length == 0 && telephone.value.trim().length == 0)
       {
         alert('手机或联系电话至少输入一个!');
         return false;
       } 
       
//       if(mobile.value.trim().length!=0)
//       {
//         var myreg = /^(((13[0-9]{1})|159|153)+\d{8})$/;
//         if(!myreg.test(mobile.value.trim()))
//         {
//            alert('手机号码格式不正确!');
//            return false;
//         } 
//       }  
//      if(telephone.value.trim().length!=0)
//      {
//        var   re   = /^\d{3}-\d{8}|\d{4}-\d{7}$/;  
//        if(!re.test(telephone.value.trim()))
//        {  
//          alert("电话号码格式不正确!"); 
//          return false; 
//        }
//      }
      
      if(validation_code.value.trim().length==0)
      {
        alert('带*为必填,请填写!');
        return false;
      }
      if(checkRead.checked==false)
      {
			alert("请阅读并选择接受用户服务协议!");
			checkRead.focus();
			return false;	
	  }
     
      return true;
   }
		
   
   function return_validator()
  {
        var vNum;
        vNum = Math.random();
        vNum = Math.round(vNum*10000);
        
        document.getElementById("img_validation_code").src="../Validator.aspx?num="+vNum;
  }  
  
    function Agree()
  {
    var div_con =document.getElementById("div_con");
    var div_info = document.getElementById("div_info");
    var txb_status = document.getElementById("txb_status");
    txb_status.value = "1";
    div_info.style.display="";
    div_con.style.display = "none";
     
  }
    function Pre()
  {
    var div_con =document.getElementById("div_con");
    var div_info = document.getElementById("div_info");
    div_con.style.display = "";
    div_info.style.display="none"; 
  }
  
  function ShowHide()
  {
     var div_con =document.getElementById("div_con");
     var div_info = document.getElementById("div_info");
     var txb_status = document.getElementById("txb_status");
     if(txb_status.value=="1")
     {
        div_info.style.display="";
        div_con.style.display = "none";
     }
  }
  function TestisSpace()
  {
    var txb_code = document.getElementById("txb_code");
    if(txb_code.value.trim().length==0)
    {
        alert('请填写帐号,再检测!');
        return false;
    }
    return true;
  }
