Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
How to set Default or NULL text in webtexteditor?
posted

I have a little text editor that is a search box. I want it to say (Search for items here) until someone clicks in the box or it contains text they have typed. I have 2 Client Side Events defined in Javascript and on the control. OnFocus and OnBlur. Below is the JScript code but it is not working. I actually get a little "Page has errors" with a sytax error icon. Any help would be appreciated:

<script type="text/javascript" id="igClientScript">
<!--

function ClearText(oEdit, text, oEvent){

 var obj = document.getElementById("txtSearch");
 obj.value = "";
 obj.style.font-style = "normal";
 obj.style.color = "black";

}

function ResetNULLText(oEdit, text, oEvent){
 
 var obj = document.getElementById("txtSearch");

 if(obj.value == "")
 {
  obj.value = "(Search for items here)";
  obj.style.font-style = "italics";
  obj.style.color = "#666666";
  
 }  
}
// -->
</script>

Parents
No Data
Reply
  • 995
    Verified Answer
    posted

    Here is the correct way to do this. Took a while to find the documentation on it.

    <script type="text/javascript" id="igClientScript">
    <!--

    function ClearText(oEdit, text, oEvent){

     oEdit.setValue("");
     //oEdit.style.font-style = "normal";
     //oEdit.style.color = "black";

    }

    function ResetNULLText(oEdit, text, oEvent){
     
     if(oEdit.getValue() == "")
     {
      oEdit.setValue("(Search for items here)");
      //oEdit.style.font-style = "italics";
      //oEdit.style.color = "#666666";
     
     }  
    }
    // -->
    </script>
     Now I have to work on setting the style.

Children
No Data