Re: Beyond MaxTextLength ... Real Time Text Characters Remaining Displayed ... Possible?

  •  09-26-2005, 4:50 PM

    Re: Beyond MaxTextLength ... Real Time Text Characters Remaining Displayed ... Possible?

    After looking at the JavaScript_API page Adam refers to above, the following code displays the number of HTML characters remaining into a textbox in the 6.02.2900 version of IE.

    The 7.2 version of Netscape and the 1.0.6 version of FireFox display an error dialog stating:

        TypeError: editdoc.attachEvent is not a function.

    If you know how to modify the code below to work with FireFox and Netscape, please let me know.

    <script language="JavaScript" type="text/javascript" >
    function CE_attachEvent()
    {
    // get the cute editor instance
    var editor1 = document.getElementById('CE_Editor1_ID');
    //Get the editor content
    var editdoc=editor1.GetDocument();
    // attach Event
    editdoc.attachEvent('onkeypress',HandleChange);
    }
     
    function HandleChange()
    {
    // get the cute editor instance
    var editor1 = document.getElementById('CE_Editor1_ID');
    //Get the editor content
    var editdoc=editor1.GetDocument();
    // alert(editdoc.body.innerHTML.length);
    var totalcharacters = 5000;
    var usedcharacters = editdoc.body.innerHTML.length;
    var txtbx = document.getElementById('txtbox1');
    txtbx.value = totalcharacters - usedcharacters;
    }
    </script>
    <html>
    <body onload="CE_attachEvent()">
     form id="Form1" runat="server">
    <CE:Editor id="Editor1" UseRelativeLinks=true EditorWysiwygModeCss="example.css" RemoveServerNamesFromUrl=true MaxHTMLLength=5001 runat="server" ></CE:Editor><br />
    <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Submit"></asp:Button>&nbsp;
    HTML Characters Remaining: <input id="txtbox1" name="HTMLCharsRemaining" type="text" /><br/><br />
    </form>
    </body>
    </html>
     
View Complete Thread