0

I have a text box:-

<asp:TextBox ID="TextBox3" runat="server" BackColor="Silver" 
            BorderColor="Silver" Height="20px" Style="margin-left: 6px" Width="136px" OnFocus = "onfocus(); return false;"></asp:TextBox>

function onfocus(){ document.getElementById('<%=TextBox3.ClientID%>').value = "";}

with default text on it, on page load:-

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // By Default the date of submission is set to current date. // 
                TextBox3.Text = "Enter Member ID";
            }

When the client clicks on the textbox, I want the default text to be cleared (empty textbox), so that the client can enter the actual ID and not have to manually delete the default text.

However the method I am visualizing, isn't working with the code that I have written.

1
  • 3
    you can consider to use html5's placeholder Commented Aug 16, 2013 at 19:05

1 Answer 1

5

How about you just use a placeholder on your input:

<asp:TextBox ID="TextBox3" placeholder="Member ID" .... ></asp:TextBox>
Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't work with IE. apparently you have to use this:- github.com/mathiasbynens/jquery-placeholder/blob/master/… still cant figure how to use that library and edit the code. Can you help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.