﻿
var lan=getCookie('language');
var flag=true;//标识符
    //登录页登录
    function checkform(){
     flag=true;
        var txtUserName=$("#txtUserName").val().Trim();
        var txtUserPass=document.getElementById('txtUserPass').value.Trim();
        var txtVili=$("#txtVili").val().Trim();
      var testName=/^[a-zA-Z]{1}([a-zA-Z0-9]){3,15}$/;
     var testPass=/^([A-Z]|[a-z]|[\d]){5,15}$/;
        //用户名
       if(txtUserName==""){
           alert( lan!=1?'请输入您的用户名':'Please enter your user name');
            $("#txtUserName").focus();
            flag=false;
            return false;
        }
        if(!testName.test(txtUserName)){
           alert(lan!=1?'您的用户名格式不正确':'Your user name format is incorrect');
            $("#txtUserName").focus();
            flag=false;
            return false;
        }
        //密码
        if(txtUserPass==""){
              alert(lan!=1?'请输入您的密码':'Please enter your password');
           document.getElementById('txtUserPass').focus();
            flag=false;
            return false;
        }
          if(!testPass.test(txtUserPass)){
             alert(lan!=1?'您的密码格式不正确':'Your password is not formatted correctly');
            document.getElementById('txtUserPass').focus();
            flag=false;
            return false;
        }
        if(txtVili==""){
         alert(lan!=1?'请输入验证码':'Please enter the verification code');
            $("#txtVili").focus();
            flag=false;
            return false;
        }
          //验证码
       if(txtVili.toLowerCase()!=getCookie('jc_user').toLowerCase()){
          flag=false;
        alert(lan!=1?'验证码错误，请重新输入!':'Code error, please re-enter!');
        $("#txtVili").focus();
        return false;
      }
     return true;
    }
      
      //首页登录 
     function Loginform(){
       checkform();
       if(flag==true){
        this.myform.submit();
        }
    }
    
    
     
 //根据cookie获取值
   function getCookie(objName){//获取指定名称的cookie的值
   var arrStr = document.cookie.split("; ");
   for(var i = 0;i < arrStr.length;i ++){
    var temp = arrStr[i].split("=");
    if(temp[0] == objName) {
    return unescape(temp[1]);
    }
   }
  
}