Posted By

ricosushi on 07/14/10


Tagged

clear search default input Value onfocus


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

ricosushi
mchadwick


Search clearance


 / Published in: JavaScript
 

Clears de default value from a input box on focus and returns its original value on blur.

  1. // search clearance
  2. function defaultInput(target){
  3. if((target).value == 'Search...'){(target).value=''}
  4. }
  5.  
  6. function clearInput(target){
  7. if((target).value == ''){(target).value='Search...'}
  8. }
  9.  
  10.  
  11. // usage
  12. <input type="text" onfocus="defaultInput(this)" onblur="clearInput(this)" value="Search..."/>

Report this snippet  

You need to login to post a comment.