Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Date Input 6 digit year

Tags:

html

date

I have a standard <input /> control on my form, decorated with type="date"

When rendered, it displays the correct watermark of yyyy-mm-dd, and you can select a date correctly.
However, when you try type in a value, the year extends to 6 digits, instead of four. I have added screenshots to help demonstrate the issue I'm having.

Is anyone else getting this? I'm using Chrome ( Version 35.0.1916.153 m ) as my default browser.
I'd like a way to force a 4year input that doesn't involve extra JS.

Date Control

Control Source

like image 943
TheGeekZn Avatar asked Jul 07 '14 06:07

TheGeekZn


People also ask

How can change date format in dd mm yyyy in HTML?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.

Can I use an HTML input type date to collect only a year?

No, you can't, it doesn't support only year, so to do that you need a script, like jQuery or the webshim link you have, which shows year only.


1 Answers

the max attribute is working, as far as i know...

the format of max is trickey, if you put the correct format everything will work fine....

see here for example:

http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_max_min_date

like image 64
Yaniv Hadad Avatar answered Sep 17 '22 18:09

Yaniv Hadad