Click here to Skip to main content
15,886,710 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 26-Dec-19 7:12am

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/[^]
 
Share this answer
 
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/[^]
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900