I am using Bootstrap for my project. The placeholders are displaying fine for all browsers except in Internet Explorer 8 and below.
Are there any solutions to get placeholder support in IE8?
I am using Bootstrap for my project. The placeholders are displaying fine for all browsers except in Internet Explorer 8 and below.
Are there any solutions to get placeholder support in IE8?
you can use this plugin https://github.com/mathiasbynens/jquery-placeholder Even works in IE6
It should'nt be to hard to figure this out without a plugin, I'm guessing something close to this will do the trick:
var test = document.createElement('input');
if (!('placeholder' in test)) {
$('input').each(function () {
if ($(this).attr('placeholder') != "" && this.value == "") {
$(this).val($(this).attr('placeholder'))
.css('color', 'grey')
.on({
focus: function () {
if (this.value == $(this).attr('placeholder')) {
$(this).val("").css('color', '#000');
}
},
blur: function () {
if (this.value == "") {
$(this).val($(this).attr('placeholder'))
.css('color', 'grey');
}
}
});
}
});
}
IE9 and below doesn't support the placeholder
attribute. See this
You can use EZPZ hints to supplement it though. Just load the script if the browser is IE
<!--[if lt IE 10]>
<script src="PATHTOFILE"></script>
<![endif]-->
EZPZ hints allows you to continue to use placeholder
for modern browsers.
Example:
<input type="text" id="search" placeholder="Search" />
$("input[type=text]").ezpz_hint();