Skip to content

Instantly share code, notes, and snippets.

@owldesign
Created January 6, 2016 22:44
Show Gist options
  • Save owldesign/00c71666fb758a2a8b31 to your computer and use it in GitHub Desktop.
Save owldesign/00c71666fb758a2a8b31 to your computer and use it in GitHub Desktop.
IE9 Placeholder Fallback
//IE9 placeholder fallback
//credits http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
if(!Modernizr.input.placeholder){
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
}).blur(function() {
var input = $(this);
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.val(input.attr('placeholder'));
}
}).blur();
$('[placeholder]').parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment