Created
December 18, 2012 10:09
-
-
Save stopsatgreen/4326822 to your computer and use it in GitHub Desktop.
Detect placeholder support in the browser and use value if it isn't present.
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
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