clearing the textbox on focus

Last post 01-11-2011, 9:01 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  01-10-2011, 7:25 AM 65653

    clearing the textbox on focus

    Hello,
     
    I'm trying to clear the text box using javascript  during the onfocus event.   Below you will find my javascript code and the vb.net code to add the attribute
     
    vb.net
                Editor1.Attributes.Add("OnFocus", "ClearEmailTextbox()")
     
    Javascript 
    function ClearEmailTextbox()
       {  
       document.getElementById('ctl00$ContentPlaceHolder1$Editor1').value = "";
       } 
     
    Thanks for your help,
    Lonnie 
  •  01-11-2011, 9:01 PM 65684 in reply to 65653

    Re: clearing the textbox on focus

    hi lonnie,
     
    I think you are using the asp.net version of editor. So please try the example below.
     
    By the way, the asp.net version forum is http://cutesoft.net/forums/23/ShowForum.aspx
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register Namespace="CuteEditor" Assembly="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>Untitled Page</title>  
    8. </head>  
    9.   
    10. <script runat="server">  
    11.     protected override void OnLoad(EventArgs e)  
    12.     {  
    13.         editor1.Text = "this is a test";  
    14.         base.OnLoad(e);  
    15.     }  
    16. </script>  
    17.   
    18. <body>  
    19.     <form id="form1" runat="server">  
    20.         <CE:Editor ID="editor1" runat="server">  
    21.         </CE:Editor>  
    22.     </form>  
    23. </body>  
    24. </html>  
    25.   
    26. <script type="text/javascript">     
    27. function CuteEditor_OnInitialized(editor)  
    28. {  
    29.     var editor1=document.getElementById("<%= editor1.ClientID %>");    
    30.     var editdoc = editor1.GetDocument();  
    31.     if(editdoc.body.addEventListener)  
    32.     {  
    33.        editdoc.addEventListener("focusin",clearContent,false);  
    34.     }  
    35.     else  
    36.     {  
    37.         editdoc.onfocusin=function()  
    38.         {  
    39.              editor1.SetHTML("");  
    40.         }  
    41.     }  
    42. }  
    43.   
    44. function clearContent()  
    45. {  
    46.     var editor1=document.getElementById("<%= editor1.ClientID %>");    
    47.     editor1.SetHTML("");  
    48. }  
    49.                
    50.           
    51. </script> 
     
     
    Regards,
     
    Ken
View as RSS news feed in XML