What browsers support the placeholder html tag for text inputs? Does Internet Explorer support it? (I have开发者_开发知识库 a JavaScript placeholder that I can use for the browsers that do not support it.)
<input type=TEXT placeholder="placeholder here" />
It is currently supported by all major browsers except IE 9 and earlier and Opera mini.
For updates, look at the w3schools-specs Or even better, view this overview.
For anyone interested, this is the jQuery Fallback that I use
I use it with jQuery Validation Engine.
Replace FORMCLASS with the class of your form.
<!-- IF IE - use Placeholder Fallback -->
<!--[if lt IE 10 ]>
<script>
$(".FORMCLASS").find('[placeholder]').each(function(){
$(this).val($(this).attr('placeholder'));
$(this).focus(function() {
if ($(this).attr('placeholder')==$(this).val()) {
$(this).val('');
}
});
});
</script>
<![endif]-->
According to this, IE 10 supports it. (You can test it here)
I fix the problem this -probably the most easiest- way:
<!--[if lt IE 10]>email:<![endif]-->
<input placeholder='email' type='text' name='email'>
Firefox also supports it since 4.0
IE is not supporting placeholders
I feel this code better and it works in all major browsers
<input id="example-email" type="text" value="Email Address" onfocus="if(this.value === 'Email Address') this.value = '';" onblur="if(this.value === '') this.value = 'Email Address';" name="example-email">
Question may have been answered a few years ago, but I found it today doing a search.
Since a good reference and pics were not provided before, I am updating this question with both.
HTML5 placeholder Attribute basically says:
The placeholder attribute is supported in all major browsers, except Internet Explorer.
FYI: This includes IE9.
In case someone is looking for a HTML5-placeholder alike solution for non-supported browsers here is a good article about it:
http://www.viget.com/inspire/a-better-jquery-in-field-label-plugin/
Placeholders are fully supported by:
- FF 4+
- Chrome 4+
- Safari 5+
- Opera 11.6+
- IE 10+
Source: Can I use input placeholder attribute?
For those who want the simplest solution, use the built-in features!
<input type="text" name="email" value="Email Address" placeholder="Email Address" onfocus="if(this.value==this.placeholder) this.value=''" onblur="if(this.value=='') this.value=this.placeholder">
Tested in chrome and IE8 :)
Note: I use this with more javascript to validate the input and give feedback inside the field itself by changing the value and placeholder at runtime.
I know it's an old question. My suggestion is to use Modernizr for detecting placeholder support! https://modernizr.com/
精彩评论