Skip to content

Instantly share code, notes, and snippets.

@jonobr1
Created March 13, 2010 15:41
Show Gist options
  • Save jonobr1/331376 to your computer and use it in GitHub Desktop.
Save jonobr1/331376 to your computer and use it in GitHub Desktop.
/* jquery.formUI by Jono Brandel
http://jonobr1.com/
This is an all purpose javascript file
to increase the usability for forms.
Dependent on jQuery.
http://jquery.com/
--------------------------------------------*/
$(function(){
var inputObject = $('input[type="text"]');
$.each(inputObject, function(i) {
var t = $(this).val();
$(this).focus(function(e) {
var either = $(this).val();
if( either == t) {
$(this).val('');
}
}).blur(function() {
var whether = $(this).val();
if(!whether) {
$(this).val(t);
}
});
});
var textareaObject = $('textarea');
$.each(textareaObject, function(i) {
var t = $(this).val();
$(this).autogrow();
$(this).focus(function(e) {
var either = $(this).val();
if( either == t) {
$(this).val('');
}
}).blur(function() {
var whether = $(this).val();
if(!whether) {
$(this).val(t);
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment