Click here to Skip to main content
14,385,812 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to add a text value in text box in html and javascript. when you load the website; the textbox has to show the sample value "Enter Your Name Here", when the user hit the textbox, it has clear the "Enter Your Name Here" value automatically. i am developing my website using HTML and Javascript. can any one help out please?
Thanks in advance.
Posted
Updated 20-Oct-19 17:54pm
Rate this:
Please Sign up or sign in to vote.

Solution 2

Davids solution is going to get you on the right path.
Here is an example of using jQuery to accomplish this along with an article that explains the code.
http://www.davidjrush.com/blog/2011/10/jquery-creating-a-textbox-text-watermark/[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

You set the value attribute of the input tag to the value you want.

e.g. <input value="something" />

See this page: http://www.w3schools.com/tags/att_input_value.asp[^]



If you are just starting out; visit here: http://www.w3schools.com/[^]
   
Comments
lisalis 18-Jan-13 13:01pm
   
if i enter the value like this; it is not working
<input type="text" value="Enter APN or Address here" name="identifytext" id="identifytext" class="text ui-widget-content ui-corner-all" style="color:#2E6E9E;width:220px;height:25px;z-index:500"></input>
lisalis 18-Jan-13 13:05pm
   
Thank you so much for your help. It is working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100