如:限制输入500字
html:
<input id="" name="" onkeyup="checkLength(this,1000)">
js:
checkLength=function(dom,maxLength){
var l=0;
for(var i=0;i<dom.value.length;i++){
if(/[\u4e00-\u9fa5]/.test(dom.value[i]))
{
l+=2;
}else{
l++;
}
if(l>maxLength){
dom.value=dom.value.substr(0,i);
}
}
}