Skip to content

Instantly share code, notes, and snippets.

@arielsalminen
Forked from stopsatgreen/Placeholder Polyfill
Created February 26, 2013 12:12
Show Gist options
  • Save arielsalminen/5038024 to your computer and use it in GitHub Desktop.
Save arielsalminen/5038024 to your computer and use it in GitHub Desktop.
function hasPlaceHolder() {
return 'placeholder' in document.createElement('input');
}
function html5forms() {
var formPlaceholder = hasPlaceHolder();
if (formPlaceholder === false) {
$('input[type=text]').each(function() {
if($(this).attr('placeholder')) {
var placeholderText = $(this).attr('placeholder');
$(this).attr('value',placeholderText);
}
});
emptyTextBox();
}
}
document.addEventListener('DOMContentReady', html5forms, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment