New Sado Version 1.1 released! Easily add ORM to your applications using our Sado Library

jQuery Form Text Field Hints Hide on Focus Show on Blur

Here is a simple function that will create a text field hint using the field title value (note this function/example uses the jquery core lib): function $$hint(f) {
      if(f.length) {
            var dval = f.attr('title');
            if(dval) {
                  if(!f.val().length) {
                        f.val(dval);
                  }
                  f.focus(function() {
                        if(f.val() == dval) {
                              f.val('');
                        }
                  }).blur(function() {
                        if(!f.val().length) {
                              f.val(dval);
                        }
                  });
            }
      }
}
Now invoke the text field hint: <input id="email" title="Your email address here" />

<script type="text/javascript">
$$hint($('#email'));
</script>
Now when the field is loaded it will contain the hint "Your email address here", as soon as the field is clicked on the hint will disappear, once the field is out of focus the hint will return if no other value has been entered in the text field.