Using HTML5 Placeholder attribute in IE7 and IE8 is possible with the help of a block of jquery code.
Here goes the code -
Here goes the code -
This file contains 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
if($.browser.msie){ | |
$('input[placeholder]').each(function(){ | |
var input = $(this); | |
$(input).val(input.attr('placeholder')); | |
$(input).focus(function(){ | |
if (input.val() == input.attr('placeholder')) { | |
input.val(''); | |
} | |
}); | |
$(input).blur(function(){ | |
if (input.val() == '' || input.val() == input.attr('placeholder')) { | |
input.val(input.attr('placeholder')); | |
} | |
}); | |
}); | |
}; |
Great. But the password field will display "*****" when using this script.
ReplyDeleteIt doesn't behave like the html5 placeholder (this one will dissapear as soon as you focus the input, the html5 waits until you type something)
ReplyDeletecool!!!... but... how can I use in my blog? (on search-box in my blog)
ReplyDeletethank you!!!
$('input[placeholder]').each(function(){
ReplyDeleteshould be
$('input').each(function(){
since ie8 doesn't even know what placeholder is.
unless you use a html5 shiv or modernizer
thanx for saving even this little time
ReplyDeletethanks a lot!
ReplyDeleteThank You
ReplyDeleteThanks a lot.
ReplyDeleteThis is the coffee version + only IE check.
https://gist.github.com/4435322
This comment has been removed by a blog administrator.
ReplyDeleteGreat, thanks so much.
ReplyDeleteNice blog, thanks for posting.
ReplyDelete