โค้ด Javascript และ HTML
<script type="text/javascript"> function clickclear(thisfield, defaulttext) { if (thisfield.value == defaulttext) { thisfield.value = ""; } } function clickrecall(thisfield, defaulttext) { if (thisfield.value == "") { thisfield.value = defaulttext; } } </script> <input id="search" type="text" name="q" value="search" onclick="clickclear(this, 'search')" onblur="clickrecall(this,'search')"/>
ตัวอย่างผลลัพธ์