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
The value property is supported in all major browsers.
Note: The <input type="month"> element is not supported in Internet Explorer or 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;
The result of x will be:
1997-11
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