Bryce
Bryce

Reputation: 6660

HTML5 date input accepts invalid dates?

Why can the HTML5 element <input type="date"> let the user scroll through the dates to an invalid date such as 31 September 2014?

DEMO: http://jsfiddle.net/oztjryx4/1/

Why does Chrome allow this to happen? How can I check if the date is invalid or does not exist?

Upvotes: 3

Views: 2321

Answers (1)

int32_t
int32_t

Reputation: 6160

You can detect such invalid dates with input.validity.badInput. According to http://crbug.com/231811, the reason is simplicity.

Upvotes: 6

Related Questions