Hi,
In my page I have the following code:
<asp:TextBox ID="SearchCriteriaTextBox" runat="server" Text="Enter Search Criteria" Width="150px" ForeColor="GrayText" OnClick="this.value = ''; this.style.color = 'black'" OnBlur="javascript:changeText('<%=SearchCriteriaTextBox.ClientID %>')" />
And for the javascript:
function changeText(txtB) {
var textBox = document.getElementById(txtB);
var txt = textBox.value;
if (txt = "") {
textBox.value = "Enter Search Criteria";
textBox.style.color = "grey";
}
}
What I'm trying to do is, when the user clicks on the TextBox, the text is cleared (this part is working) and when the user clicks outisde the textBox the text "Enter Search Criteria" is shown again, but only if the the textBox is empty. The problem is that on the function changeText the variable textBox is null, but I don't understand why.
Does anyone know what is wrong?
Thanks in advance,
Ana