TextBox with default value

I want to use a text box with text.

For example: Someone@example.com. When the user clicks on it, the text field is cleared and ready for user input.

sample textbox

+4
source share
6 answers

If you are working on newer browsers, you can use the placeholder property, which is new in HTML 5

 <asp:TextBox ID="textBox1" runat="server" placeholder=" Someone@exmaple.com "></asp:TextBox> 

otherwise you can also use the onfocus and onblur event for this, as described here

+5
source

you can use it so simple

  <input class="status" type="text" size="5" placeholder="started" /> 

placeholder show you the text you want

Hope this helps you!

+1
source

You can do the following:

  • Add a text box to your web page.
  • Set the default text in the obj.Text property.
  • Add properties (focus and blur events).
  • In the focal event, check to see if value = Someone@exmaple.com , and then an empty text field.
  • When blurring, check if the text field is empty, then set the text: Someone@exmaple.com

Hope that helps

0
source

You can use this as

 <TextBox ID="txtone" runat="server" tooltip="Enter comments" onblur="if(this.value=='') this.value=' Someone@exmaple.com ';" onfocus="if(this.value == ' Someone@exmaple.com ') this.value='';" Text=" Someone@exmaple.com "></TextBox> 
0
source

Try this to manage your server:

 <asp:TextBox ID="textBox1" runat="server" placeholder=" Someone@exmaple.com "></asp:TextBox> 

For an HTML control:

 <input Type="Text" ID="textBox1" placeholder=" Someone@exmaple.com " /> 
0
source

You can use this ajax if you need a cross browser compatible version.

 <ajaxToolkit:TextBoxWatermarkExtender ID="EmailClear" runat="server" TargetControlID="EmailAddress" WatermarkText=" Someone@example.com " /> 

You just need to add this under each field.

0
source

All Articles