Input Month value Property
Example
Set the month and year for a month field:
document.getElementById("myMonth").value = "2014-02";
Try it Yourself »
Definition and Usage
The value property sets or returns the value of the value attribute of a month field.
The value attribute specifies a month and year for the month field.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | 10.0 | Yes | Yes | Yes |
Note: The <input type="month"> element does not show any date field/calendar in Firefox.
Syntax
Return the value property:
monthObject.value
Set the value property:
monthObject.value = YYYY
-MM
Property Values
Value | Description |
---|---|
YYYY-MM |
Specifies the month and year. Explanation of components:
|
Technical Details
Return Value: | A String, representing the month and year of the month field |
---|
More Examples
Example
Get the month and year of a month field:
var x = document.getElementById("myMonth").value;
Try it Yourself »
Example
An example that shows the difference between the defaultValue and value property:
var x = document.getElementById("myMonth");
var defaultVal = x.defaultValue;
var currentVal = x.value;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
❮ Input Month Object