如何检测fck的剩余输入字数, fck没有onkeyup这个事件来响应方法,要怎么做呢。如果输入字数达到了能否限制输入?不好意思,就这么点分了

解决方案 »

  1.   

    给你个JS,参考一下
    function checkLength(which,clen,str) { 
        var maxChars = clen; //
        var strLbl = str;
        if (which.value.length > maxChars) 
        {
            //alert("您出入的字数超多限制!");
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0,maxChars); 
            return false;
        }
        else
        {
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById(strLbl).innerHTML = curr.toString(); 
            return true;
        }

    <asp:TextBox ID="txt" runat="server"  onkeyup="checkLengt(this,500,'sy');"></asp:TextBox>
                                        <span id="sy" style="color: Red;"></span>限500字
      

  2.   

    谢谢回复,这个方法我知道,这个在限制textbox时用onkeyup这个事件可以实现,但对fck不能用onkeyup这个事件,不知道要怎么绑定方法。
      

  3.   

    参考这个帖子
    http://snipplr.com/view/28453/add-maximum-length-and-counter-to-ckeditor-fckeditor/
    结合的是jquery
      

  4.   

    正合你意
    http://ghost-fly.javaeye.com/blog/482880