<input name="myfield" type="date" value="2014-06-27">
| [reply] [d/l] |
Thanks, Is this summary not accurate then?
http://caniuse.com/input-datetime
| [reply] |
For those browsers without support for type="date", the input field falls back to text entry.
Also, there exists Modernizr.js, which is a useful shim to add support for recent HTML features to older browsers.
| [reply] [d/l] |
tobyink offers the modern HTML(5) way. You also asked about validation. You RFC:MUST not trust user input, Validation is only secure on the server side. JS has no say whatsoever in what a hacker decides to send or an old or non-compliant browser submits. Check all user data. I personally tend to reach for Date::Calc’s check_date for raw validation. Up to you to decide what ranges are acceptable beyond the pure validity of the YYYY, MM, DD given to it.
| [reply] [d/l] |
Thanks, I was actually starting to use date::simple and just wondered if there was a more modern way.
| [reply] |
Please be aware that in many (probably most) countries of the world, the most common format for dates is DD/MM/YYYY or DD-MM-YYYY (i.e. with the day in the month before the month). So you'd better make clear to the user what you expect.
| [reply] |