Friday 11 November 2011

Javascript onBlur function

Desc: When you click on the textbox the value of textbox is cleared by using Javascript
method.
function doEmptytextbox(id, txtVal)
{
         var searchtext = document.getElementById(id).value;
          if (searchtext == txtVal) {
          document.getElementById(id).value = "";
          }
}

function dorestoretextbox(id, txtVal)
{
         var searchtext = document.getElementById(id);

          if (searchtext.value == "") {
          document.getElementById(id).value = txtVal;
          }
}

When TextBox is in Master Page!... code goes like this.

<asp:TextBox ID="txtNcid" runat="server" BackColor="White" ForeColor="Black" Text="(New)/Search"onblur = "return dorestoretextbox('ctl00_MainContent_txtNcid', '(New)/Search');" onclick="return doEmptytextbox('ctl00_MainContent_txtNcid', '(New)/Search');" Font-Bold="true"></asp:TextBox>

No comments:

Post a Comment