W3C validation error for input type=date
Asked Answered
H

1

10
<input type="date" max="1995-12-31" class="form-control" id="dob"/>

When I try to validate with W3C I got error for this line:

The date input type is not supported in all browsers. Please be sure to test, and consider using a polyfill.

How to solve it?

Hent answered 18/8, 2017 at 5:24 Comment(0)
M
12

Maintainer of the W3C HTML checker (validator) here. That message is just a warning message, not an error. And the reason we have the HTML checker emit that warning is, input type=date isn’t supported in desktop Safari or Internet Explorer, nor in versions of Firefox before Firefox 57, nor on Android before Android 4.4.

For the exact details about browser support, see https://caniuse.com/#search=date

So that warning’s purpose is to give you a heads-up that your document has a feature that doesn’t work as specified for users of Internet Explorer, Safari, and older versions of Firefox and Android.

That’s why the warning specifically mentions that you consider using a polyfill—in order to ensure that the feature works for all your users as expected.

To make input type=date work in all browsers, you can choose among many available polyfills:

Metalliferous answered 18/8, 2017 at 5:32 Comment(4)
Thank you for your response but how to make it work in all browserHent
To make it work in all browsers, you can use a polyfill. I’ve updated the answer to add a list of some of the polyfills availableMetalliferous
If you use the polyfill the warning goes away?Marutani
First three links have no deps. Others require jQuery. Link 1 is a fork of link 3. Awesome list!Genova

© 2022 - 2024 — McMap. All rights reserved.