javascript method.

//****************************************************************
//* 名  称:DataLength
//* 功    能:计算数据的长度
//* 入口参数:fData:需要计算的数据
//* 出口参数:返回fData的长度(Unicode长度为2,非Unicode长度为1)
//*****************************************************************
function DataLength(fData)
{
    var intLength=0
    for (var i=0;i<fData.length;i++)
    {
        if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255))
            intLength=intLength+2
        else
            intLength=intLength+1    
    }
    return intLength
}


//****************************************************************
//* 名  称:DataLength
//* 功    能:计算数据的长度
//* 入口参数:fData:需要计算的数据
//* 出口参数:返回fData的长度(Unicode长度为2,非Unicode长度为1)
//*****************************************************************
function DataLength(fData)
{
    var intLength=0
    for (var i=0;i<fData.length;i++)
    {
        if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255))
            intLength=intLength+2
        else
            intLength=intLength+1    
    }
    return intLength
} 

//****************************************************************
//* 名  称:IsEmpty
//* 功    能:判断是否为空
//* 入口参数:fData:要检查的数据
//* 出口参数:True:空                              
//*           False:非空
//*****************************************************************
function IsEmpty(fData)
{
    return ((fData==null) || (fData.length==0) )
} 


//****************************************************************
//* 名  称:IsDigit
//* 功    能:判断是否为数字
//* 入口参数:fData:要检查的数据
//* 出口参数:True:是0到9的数字                              
//*           False:不是0到9的数字 
//*****************************************************************
function IsDigit(fData)
{
    return ((fData>="0") && (fData<="9"))
} 
原文地址:https://www.cnblogs.com/fengys-moving/p/3462906.html