val().length這樣獲取的字符長度 不是實際的啊,比如中文字符它不能識別為2個字節。
1 回答

偶然的你
TA貢獻1841條經驗 獲得超3個贊
String.prototype.len = function() // 給string增加個len ()方法,計算string的字節數
{
return this.replace(/[^\x00-\xff]/g, "xx").length;
}
然后val().len()就行了
- 1 回答
- 0 關注
- 685 瀏覽
添加回答
舉報
0/150
提交
取消