Input Month min Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month

Description

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

Set the min property with the following Values

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

Return Value

A String, representing the minimum month and year allowed

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Month:/*from   w  w w.ja v  a  2  s  .  c o  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").min;
    document.getElementById("demo").innerHTML = v;
}
</script>
</body>
</html>

Related Tutorials