Adding a stripHTML function and counting characters

  •  08-26-2005, 5:50 PM

    Adding a stripHTML function and counting characters

    I have a need to be able to count the non-HTML characters in the CE fields. For this reason, I've been trying to modify the include to add a javascript function to the textarea. However, no matter what I place in the onBlur, it won't execute (even a simple alert). All my logic works correctly in the non-RTE textarea (I started there and got it perfected). But when I transition to adding it to the RTE, I get nothing onBlur.

    Does CE somehow block onBlur?

    Here is my relevant code. First chunk is my external JS function, second chunk is a snippet of include_CuteEditor.asp. I added a property s_maxRTElength by duplicating the format of s_maxhtmllength.

    <SCRIPT LANGUAGE="JavaScript">
    function checkLength(toCheck, maxLength) {
        var stripped = toCheck.replace(/(<([^>]+)>)/ig,"");
        var diff = stripped.length - maxLength;
        if (diff > 0) {
            alert('The maximum length for this statement is ' + maxLength + ' characters (roughly 5 pages). Your entry exceeds that length by ' + diff + '.');
            this.focus();
        }
    }
    </SCRIPT>


    Response.Write "<TEXTAREA name="""&ID&""" rows="""&s_textareaRows&""" cols="""&s_textareaCols&""" style=""DISPLAY: none; WIDTH: " & s_width & "; HEIGHT: " & s_height & """ ID="""&ID&""" onBlur=""checkLength(this.value, " & s_maxRTElength & ");"">" & Server.HTMLEncode( s_Text ) & "</TEXTAREA>"


    Any help would be appreciated. It's important for us to be able to count the non-html characters. If there's an easier way to do this, by all means, let me know!

    Thanks,
    Jess
View Complete Thread