function limitLength(obj, length) { var desc = obj.value; obj.value = substr(obj.value, length); } function substr(str, length) { var l = 0, i = 0; while (l < length && i < str.length) { l += 1; if (str.substring(i, i + 1).match(/[\u4e00-\u9fa5]/)) l += 2; i += 1; } return str.substring(0, i); }