•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 374,571 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,617 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Use
This script can be used to mimize space of a textfield by putting the title of the field inside the text field itself when the page loads. This title will then disapear when it is clicked.
How To Use
Use the following code as your textfield and fill in the "value" property with the text that you want appear inside the field.
I hope you can use this handy code somewhere
This script can be used to mimize space of a textfield by putting the title of the field inside the text field itself when the page loads. This title will then disapear when it is clicked.
How To Use
Use the following code as your textfield and fill in the "value" property with the text that you want appear inside the field.
I hope you can use this handy code somewhere
<input onfocus="this.value=''" name="Search" type="text" value="Search"/>
Comments (Newest First)
tavox | Newbie Poster | Mar 22nd, 2007
•
•
•
•
Nice job, the original code i already know but the comments posted are very helpful.
MattEvans | Posting Shark | Jan 29th, 2007
•
•
•
•
ah... but what if nothing and Search are valid values?
[html]
<input type="text" name="txt" value="Search"
onfocus="if(this.beenchanged!=true){ this.value = ''}"
onblur="if(this.beenchanged!=true) { this.value='Search' }"
onchange="this.beenchanged = true;"/>
[/html]
[html]
<input type="text" name="txt" value="Search"
onfocus="if(this.beenchanged!=true){ this.value = ''}"
onblur="if(this.beenchanged!=true) { this.value='Search' }"
onchange="this.beenchanged = true;"/>
[/html]
~s.o.s~ | Rebellion Revamped | Jan 20th, 2007
•
•
•
•
But this code won't work if the text field loses focus and then gains it again and for a variety of other conditions. With a bit of tweaking you guys should get the desired result. Here is my stab at it...:
html Syntax (Toggle Plain Text)
<html> <head> <title>Cool Text Effect</title> </head> <body> <label>Click on this text box </label> <input type="text" name="txt" value="Search" onfocus="if(this.value == 'Search') { this.value = ''} " onblur="if(this.value == '') { this.value='Search'; }" /> </body> </html>
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)