JS控制输入字符长度

     <script language="javascript" type="text/javascript">
    function checkLength(ctl)
    {
       var maxLength=200;
       var nowLength=ctl.value.length;        
       if (nowLength>maxLength)
       {
            ctl.value=ctl.value.substring(0,maxLength);                      
       }
    }
    </script>

 

调用时:onkeyup="checkLength(this);"

posted on 2008-12-11 17:27  王培  阅读(629)  评论(0编辑  收藏  举报

导航