This is a super light weight plugin (only 20 lines an 661bytes. (No compression needed).
What does it do?
It removes the value of a text/password when the user focues on the field.
that's it...
How to use it$(selector).clearfield();
Options
There are only one option, "not".
This will prevent input fields with a certain class-name to remove
the default value. This is great of you are using this plugin on a form
that fetches data from a database etc.
Example:
$('form').clearfield({not:'not-on-this'});
...
<input type="text" value="Loaded from db" class="not-on-this" />
SOURCE CODE:
// ClearField Plugin, Created by: Stian Jacobsen.
// Usage: $(selector).clearfield({not:'classname'});
$.fn.clearfield = function(options) {
var self = this;
options = jQuery.extend({not: 'not-on-this-one'}, options);
var clearfield = function() {
var a = $(this);
if(a.attr('rel') == undefined) { a.attr('rel', a.val()); }
a.focus(function() {
if(a.val() == a.attr('rel')) { a.val(''); }
}).blur(function() {
if(a.val() == '') { a.val(a.attr('rel')); }
});
};
return self.each(function() {
$('input[@type=text], input[@type=password]', self).not('.'+options.not).each(clearfield);
});
}