JS判断字符长度

	var jmz = {};
	jmz.GetLength = function(str) {
	    return str.replace(/[\u0391-\uFFE5]/g,"aa").length;   //先把中文替换成两个字节的英文,在计算长度
	};  	 
	alert(jmz.GetLength('测试测试ceshiceshi'));

参考链接

猜你喜欢

转载自blog.csdn.net/seven_north/article/details/87073473