The min
attribute from input date field
specifies the minimum value (date) for a date field.
The min
property sets or gets the value of the min attribute of a date field.
min |
Yes | No | No | Yes | Yes |
Return the min property.
var v = inputdateObject.min
Set the min property.
inputdateObject.min=YYYY-MM-DD
Value | Description |
---|---|
YYYY-MM-DD | Set the minimum date value allowed for the date field.
|
A String type value representing the minimum date allowed.
The following code shows how to change the minimum date.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. j a va 2 s. c o m-->
Date:
<input type="date" id="myDate" name="bday" min="1980-01-01" max="2000-01-01">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myDate").min = "1999-01-01";
document.getElementById("demo").innerHTML = "changed";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to use get the minimum date allowed for a date field.
<!DOCTYPE html>
<html>
<body>
Enter a date between 1980-01-01 and 2000-01-01:
<input type="date" id="myDate" name="bday" min="1980-01-01" max="2000-01-01">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w. ja va 2 s . c o m-->
var x = document.getElementById("myDate").min;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: