Created
May 21, 2010 12:15
-
-
Save petersendidit/408763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!Modernizr.input.placeholder) { | |
$(':input[placeholder]').live('focus',function(){ | |
var input = $(this); | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); | |
} | |
}).live('blur',function(){ | |
var input = $(this); | |
if (input.val() == '') { | |
input.val(input.attr('placeholder')); | |
} | |
}).trigger('blur'); | |
$(document).bind('ajaxSuccess', function(){ | |
$(':input[placeholder]').trigger('blur'); | |
}); | |
// Uses events added by the jQuery Form plugin http://jquery.malsup.com/form/ | |
// Make sure we don't submit placeholder text | |
$('form').live('form-pre-serialize',function() { | |
$(this).find(':input[placeholder]').each(function() { | |
var input = $(this); | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); | |
} | |
}); | |
}).live('form-submit-notify',function(){ | |
$(this).find(':input[placeholder]').blur(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment