Form value 'cleaner'

/ Published in: JavaScript
Save to your folder(s)

When there's a value in a textbox, like 'search', it disappears when you click on it, and reappears when you leave (blur) it. But only if you haven't filled in anything ofcourse.
Use it like this:

Copy this code and paste it in your HTML
  1. function clean(element, what){
  2. value = element.value;
  3. if(value==what)element.value="";
  4. if(value=="")element.value=what;
  5. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.