Clearing default input values
Here is a quick and easy snippet to remove default values from input fields on focus. For each result, it clears the default value onfocus and restores the default if the value is empty onblur.
1(function($){ $.fn.clearDefaultVal = function(){ return this.each(function(){ var default_value = $(this).val(); $(this).focus(function(){ if ($(this).val() == default_value) $(this).val(""); }); $(this).blur(function(){ if ($(this).val() == "") $(this).val(default_value); }); }); }; })(jQuery); $('input.cleardefault').clearDefaultVal();
TweetBacks

There are no comments for this entry.
[Add Comment] [Subscribe to Comments]