Pre-filled fields with clean on focus & filling on blur

1
2
3
4
5
6
7
8
9
10
11
$('.inputs_class').focus( function() {
   if ($(this).val() == $(this).attr('rel'))
   {
      $(this).val('');
   }
}).blur( function() {
   if ($(this).val() == "")
   {
      $(this).val($(this).attr('rel'));
   }
});

<input name=”firstname” type=”text” value=”First Name” rel=”First Name” class=’inputs_class’ />

One thought on “Pre-filled fields with clean on focus & filling on blur”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>