﻿//全局通用JS文件

//获取对象
function GetObj(objName){
    if(document.getElementById){
        return document.getElementById(objName);
    }
    else if(document.layers){
        return document.layers[objName];
    }
    else{
        return document.all(objName);
    }
}

//去掉字符串的前后空格
String.prototype.Trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g,"");
}

//判断是否为空
function IsEmpty(obj){
    return (obj.value=="");
}

//将回车指定到按钮提交 Start
var btnObj_Glb = null;

function enterClick(name){
    btnObj_Glb = document.getElementById(name);
}

document.onkeydown = function(){
    if(window.event.keyCode == 13){
        if(btnObj_Glb != null){
            btnObj_Glb.click();
            return false;
        }
        else{
            return true;
        }
    }
    else{
        return true;
    }
}
//End


//Start 判断输入字符串是否符合指定的长度区间
function ValiStrLength(vStr,vMinLength,vMaxLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength < vMinLength){
        return false;
    }
    else if(vLength > vMaxLength){
        return false;
    }
    else{
        return true;
    }
}


function ValiStrLengthMin(vStr,vMinLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength < vMinLength){
        return false;
    }
    else{
        return true;
    }
}

function ValiStrLengthMax(vStr,vMaxLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength > vMaxLength){
        return false;
    }
    else{
        return true;
    }
}

//End


