April 19, 2012

Text box with default text

Question by anna

I have a text box with a default text. I am using javascript to dissapear it when the user clicks in this, but i want to make it work without javascript. Is there any way to do that in html or php? Thank you!

Answer by zellio

It can be done in flat HTML5 using the placeholder attribute of the <input> tag

<input type="text" placeholder="Default Text" />

Answer by Starx

In HTML5, there has been the introduction of new attribute called placeholder

You can use it like this

<input type="text" placeholder="text to show and hide" />

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!