$("input").keyup(function(){
name_length=getLength($(this).val());
console.log(name_length)
})
function getLength(str){
return str.replace(/[^\x00-xff]/g,"xx").length;
}
原文:http://www.cnblogs.com/gaogan/p/6827884.html