I have a search input field box that is blank, not even a blinking courser. I want by default to have some text and blinking courser already in the search input box that will disappear once the user clicks inside the box or starts typing. Is this possible? Can this be done without using JavaScript or anything complicated? Thanks. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" media="screen" href="search.css" /> <title>search</title> </head> <body> <div id="form"> <form action="/search.php" method="post"> <label id="sch"><input type="text" name="name" size="22" title="Subject"/></label> <p id="button"><input type="submit" value="Search:" /></p> </form> </div> </body> </html>
Try this, you can change the word search to whatever you wish: <input type="text" name="search" size="15" value="search" onblur="if(this.value=='') this.value='search';" onfocus="if(this.value=='search') this.value='';" />
Thanks for your replies. That seems to work for me. I thought JavaScript might be more involved than that.
It won't function correctly if javascript is disabled in the user's browser, but the overwhelming majority would have no reason to do that. I use the code in my search box with google's Site Search - works beautifully