Detect if input type="date" supports placeholder

html, javascript, jquery, modernizr

Solution

The W3 validator says placeholder attributes are not valid on date inputs. Validating this HTML:

<!doctype html>
<title>date placeholder test</title>
<input type="date"  placeholder="enter a date">

Gives the error: "`Attribute placeholder not allowed on element input at this point.`" ... and says you can use the attribute "`placeholder when type is text, search, url, tel, e-mail, password, or number`".

Also, Chrome doesn't show the placeholder for date inputs, even though it thinks the attribute exists in JS (this is roughly how Modernizr checks for attributes):

var test = document.createElement(element);
test.type = 'date';
alert('placeholder' in test);

Problem

Is it possible to detect if the browser supports `input type="date"` with `placeholder`?

Original source