homepage Welcome to WebmasterWorld Guest from 54.234.128.25
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
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
whatson




msg:4483383
 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?

 

daveVk




msg:4483479
 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.

rwilson




msg:4483543
 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">

Fotiman




msg:4483572
 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.
[diveintohtml5.info...]

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