Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 "placeholder" support

How can I find out if the browser supports the HTML5 placeholder tag, so I can decide whether to hook my jQuery placeholder plugin or not.

like image 673
Alex Avatar asked Aug 14 '11 22:08

Alex


People also ask

What is placeholder in html5?

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.

Why my placeholder is not working in HTML?

If you have an input in your form and placeholder is not showing because a white space at the beginning, this may be caused for you "value" attribute. In case you are using variables to fill the value of an input check that there are no white spaces between the commas and the variables.

Can we use placeholder in checkbox?

Yes, of course.

How do you put a placeholder in HTML?

If you want to set a hint for text area or input field, then use the HTML placeholder attribute. The hint is the expected value, which gets displayed before the user enters a value, for example, name, details, etc.

What is a placeholder in HTML5?

HTML5’s placeholder Attribute. HTML5 has introduced many features to the browser; some HTML-based, some in the form of JavaScript APIs, but all of them useful. One of my favorites if the introduction of the placeholder attribute to INPUT elements. The placeholder attribute shows text in a field until the field is focused upon, then hides the text.

How do I check for placeholder support in the browser?

Since placeholder is a new capability, it's important to check for support in the user's browser: function hasPlaceholderSupport() { var input = document.createElement('input'); return ('placeholder' in input); }

Is HTML5 placeholder available in webform textbox control?

you can see that we now have the html5 placeholder as part of asp.net webform textbox control. similarly any other attributes which is not supported currently can be customized as we did for placeholder attribute.

How to add a placeholder attribute to a text input?

if we talk from a plain html perspective, in order to support the placeholder attribute, all we need to do is to add a attribute named “placeholder” and provide a value to that attribute on a input control of type text. so here is how the html will look like:


1 Answers

var placeholderSupported = ( 'placeholder' in document.createElement('input') );

The variable placeholderSupported will be true if it is natively supported. Otherwise, it'll be set to false.

like image 52
Joseph Silber Avatar answered Oct 05 '22 11:10

Joseph Silber