获取输入的字符长度

//获取输入的字符长度
function findInputLength(inputString)
{
    var charCount = 0;
    for (var i = 0; i < inputString.length; i++)
    {
        if (inputString.charCodeAt(i) >= 0 && inputString.charCodeAt(i) <= 255)
        {
            charCount += 1;
        }
        else
        {
            charCount += 2;
        }
    }
    return charCount;
}

posted on 2011-03-18 11:24 matchcolor 阅读(41) 评论(0) 编辑 收藏