简体   繁体   中英

How to set a default year value to an input with type date?

I'm looking to know if it's possible to have an input of the type date to have the default year as 2017. All I can do is set a default date which includes the day and the month too:

 <input type="date" value="2017-12-21"> <br><br> <input type="date" value="2017-mm-dd"> <br><br> <input type="date" value="2017"> <br><br> <input type="date"> 

I want it to display the day as dd , the month as mm and the year as 2017 .

   <input type="date"  min="2017-01-01" max="2017-12-30">

Try min and max properties like this. It should work

Try this, as a work around, if all else fails...

Here's the WORKING DEMO

<form>
 <div>
  <input type="date" min="2017-01-01" max="2017-12-31">
 </div>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM