“the j stands for Jararaca”
about me | research blog | wordpress plugins | jQuery plugins

29 July, 2011

jQuery Clear-on-Focus Plugin

A small jQuery plugin I wrote which I thought I would make public. Instead of using <label> elements for each of your form’s fields, use the input’s value attribute to set the label. Clear-on-focus will then take care of clearing the value when a user clicks or focuses the field. If they leave the field blank, the original message is reset back. Also works correctly for password fields. Example usage:

<input type="text" name="username" value="Enter username" class="clear-on-focus" />
<input type="text" name="password" value="Enter password" class="clear-on-focus password" />

Link: github repository