No edit summary
Line 2: Line 2:
month
month
===Type===
===Type===
_input
input
===Synopsis===
===Synopsis===
How to render a month/year input field  
How to render a month/year input field  
===Description===
===Description===
'''_input''' elements of type '''month''' create input fields that let the user enter a month and year allowing a month and year to be easily entered. The value is a string whose value is in the format "YYYY-MM", where YYYY is the four-digit year and MM is the month number.  
'''input''' elements of type '''month''' create input fields that let the user enter a month and year allowing a month and year to be easily entered. The value is a string whose value is in the format "YYYY-MM", where YYYY is the four-digit year and MM is the month number.  
===Parameters===
===Parameters===
type="month"
type="month"
Line 13: Line 13:
===Example===
===Example===
<syntaxhighlight lang="html">
<syntaxhighlight lang="html">
<_label for="bday-month">What month were you born in?</_label>
<label for="bday-month">What month were you born in?</label>
   <_input id="bday-month" type="month" name="bday-month" />
   <input id="bday-month" type="month" name="bday-month" />
</syntaxhighlight>
</syntaxhighlight>
<_label for="bday-month">What month were you born in?</_label>
<label for="bday-month">What month were you born in?</label>
   <_input id="bday-month" type="month" name="bday-month" />
   <input id="bday-month" type="month" name="bday-month" />
===Note===
===Note===
When not a correct month is entered, the browser will fallback to a text-input field. Read the link below how to handle these situations.  
When not a correct month is entered, the browser will fallback to a text-input field. Read the link below how to handle these situations.  

Revision as of 22:04, 13 December 2022

Name

month

Type

input

Synopsis

How to render a month/year input field

Description

input elements of type month create input fields that let the user enter a month and year allowing a month and year to be easily entered. The value is a string whose value is in the format "YYYY-MM", where YYYY is the four-digit year and MM is the month number.

Parameters

type="month"

All other valid parameters for an input field are valid. Additionally you can use min, max, step and list.

Example

<label for="bday-month">What month were you born in?</label>
  <input id="bday-month" type="month" name="bday-month" />

 

Note

When not a correct month is entered, the browser will fallback to a text-input field. Read the link below how to handle these situations.

Also note that not all browsers support the month attribute.

Links

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month