//将中文字转换为两个英文长度
var slength=s.value.replace(/[^/x00-/xff]/g,"**").length;
//另外一种写法
String.prototype.length2 = function() {
var cArr = this.match(/[^x00-xff]/ig);
return this.length + (cArr == null ? 0 : cArr.length); }
var str="test测试";
alert(str.length2());