Posted By

lfatr on 02/16/10


Tagged


Versions (?)

SEARCHBOX ONCLICK CLEAR / UNCLEAR


 / Published in: JavaScript
 

  1. <script type="text/javascript">
  2. // searchbox functions ( clear & unclear )
  3. function clickclear(thisfield, defaulttext) {
  4. if (thisfield.value == defaulttext) {
  5. thisfield.value = "";
  6. }
  7. }
  8.  
  9. function clickrecall(thisfield, defaulttext) {
  10. if (thisfield.value == "") {
  11. thisfield.value = defaulttext;
  12. }
  13. }
  14. </script>
  15.  
  16. <input id="search" type="text" name="q" value="search" onclick="clickclear(this, 'search')" onblur="clickrecall(this,'search')"/>

Report this snippet  

You need to login to post a comment.