form中限制文本字节数js代码

2019-06-02 18:08:59于海丽

    } else {
            //当为奇数时
            size = (count - 1) / 2 + (byteLength * 1 - count);
            limitvalue = value.substr(0, size);
    }
   alert(title + "最大输入" + byteLength + "个字节(相当于"+byteLength /2+"个汉字)!");
   document.getElementById(attribute).value = limitvalue;
   return;
}