<input id="T1" size="20" onkeydown="Check(this)" onpaste="return false"  oncopy="return false;" oncut="return false;" >
<script>
function Check(src){
       var Temp=src.value.substring(0,src.value.length-1);
       if(src.value.length>10)
          src.value=Temp;
}
</script>

解决方案 »

  1.   

    有点问题
    1 为什么闭掉copy,paste...
    2 Check更存在问题
      

  2.   

    闭掉copy,paste...更完美些
    用onpropertychange不用keydown了
      

  3.   

    check()遇到来自输入法的字符,就有问题.
      

  4.   

    //for(i=1 to 
    如果字符的Asci马不再0到128之间,则为中文或者双字节文字,长度+2,否则,长度+1
    var iLen=0;for(var i=0;i<text.value.length;i++){
       if(etext1.value.substring(i,i+1).charCodeAt(0)>128){
          iLen++;//li
       }       
                 //leng
       iLen++
    }alert(iLen)