Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML
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 18-Jan-13 6:43am
lisalis197
Rate this: bad
good
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/[^]
  Permalink  
Comments
lisalis at 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 at 18-Jan-13 13:05pm
   
Thank you so much for your help. It is working.
Rate this: bad
good
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/[^]
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,400
2 CPallini 5,240
3 George Jonsson 3,584
4 Gihan Liyanage 2,625


Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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