Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholders are not displaying in IE8 for Bootstrap

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?

like image 849
user521024 Avatar asked Nov 07 '12 12:11

user521024


3 Answers

you can use this plugin https://github.com/mathiasbynens/jquery-placeholder Even works in IE6

like image 94
Ruben Avatar answered Nov 09 '22 23:11

Ruben


you can use jquery watermark plugin for that

https://code.google.com/p/jquery-watermark/

like image 21
rahul Avatar answered Nov 10 '22 01:11

rahul


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');
                         }
                       }
                   });
        }
    });
}
like image 40
adeneo Avatar answered Nov 09 '22 23:11

adeneo