Input Month max Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month

Description

The max property sets or gets the max attribute of a month field, which controls the maximum month and year for a month field.

Set the max property with the following Values

Value Description
YYYY-MM Sets the maximum month and year allowed.
  • YYYY - year (e.g. 2011)
  • MM - month (e.g. 01 for January)

Return Value

A String, representing the maximum month and year allowed

The following code shows how to get the maximum month and year allowed for a month field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Month:/*from  w  ww.ja  v a 2 s . co  m*/
<input type="month" id="myMonth" min="2018-04" max="2018-09">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myMonth").max;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials