js代码
[removed]
//显示限制输入字符method
function textAreaChange(obj){
var $this = $(obj);
var count_total = $this.next().children('span').text();
var count_input = $this.next().children('em');
var area_val = $this.val();
if(area_val.len()>count_total){
area_val = autoAddEllipsis(area_val,count_total);//根据字节截图内容
$this.val(area_val);
count_input.text(0);//显示可输入数
}else{
count_input.text(count_total - area_val.len());//显示可输入数
}
}
//得到字符串的字节长度
String.prototype.len = function(){
return this.replace(/[^\x00-\xff]/g, "xx").length;
};