Re: How to display javascript alert for exceeding text length?

  •  09-07-2015, 9:02 AM

    Re: How to display javascript alert for exceeding text length?

    Hi,

     

    Try the way below please.

     

    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5. <html xmlns="http://www.w3.org/1999/xhtml">  
    6. <head id="Head1" runat="server">  
    7.     <title>GetPlainText</title>  
    8. </head>  
    9. <body>  
    10.     <form id="form1" runat="server">  
    11.         <CE:Editor ID="editor1" runat="server">  
    12.         </CE:Editor>  
    13.         <input type="button" value="GetPlainText" onclick="GetPlainText()" />  
    14.         <div id="plainText" style="visibility: hidden">  
    15.         </div>  
    16.     </form>  
    17. </body>  
    18. </html>  
    19.   
    20. <script>  
    21. function isIE() {  
    22.     if (window.navigator.userAgent.toLowerCase().indexOf("msie") != -1) return true;  
    23.     else return false;  
    24. }  
    25.   
    26. function GetPlainText() {  
    27.   
    28.     var editor1 = document.getElementById('<%= editor1.ClientID %>');  
    29.     var plainText = document.getElementById("plainText");  
    30.     plainText.innerHTML = editor1.GetHTML();  
    31.     var text;  
    32.     if (isIE()) {  
    33.         text = plainText.innerText;  
    34.     }  
    35.     else {  
    36.         text = plainText.textContent;  
    37.     }  
    38.   
    39.     alert(text.length);  
    40.     plainText.innerHTML = "";  
    41. }  
    42. </script>  
     

    Regards,

     

    Ken 

View Complete Thread