homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Form values that disappear on click

 5:28 am on Aug 10, 2012 (gmt 0)

You know those search forms that have something like "Enter your text here" as an initial value in them, then you click in the field, and the text disappears.
How is that done? I assume it's java, but I guess it could be css. Either way, how do you do it?



 11:37 am on Aug 10, 2012 (gmt 0)

see [webmasterworld.com...] for JavaScript solution ( java is something completely different ). Not aware of css solution.


 2:21 pm on Aug 10, 2012 (gmt 0)

Try this.

<input type="text" onblur="if (this.value=='') { this.value='Please enter your text'; }" onfocus="if (this.value=='Please enter your text') { this.value=''; }" value="Please enter your text" id="search" name="search">


 3:18 pm on Aug 10, 2012 (gmt 0)

HTML5 has added a "placeholder" attribute, so you don't need any scripting for this at all.

Internet Explorer 9 or earlier doesn't support this, so you'd still need a JavaScript solution for those cases.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved