The min
attribute from input datetime element
specifies the minimum value for a datetime field.
The min
property sets or gets the value of the min attribute of a datetime field.
min |
No | No | No | No | No |
Return the min property.
var v = datetimeObject.min
Set the min property.
datetimeObject.min=YYYY-MM-DDThh:mm:ssTZD
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD | Set the minimum date and time for the datetime field.
|
A String type value representing the minimum date and time allowed.
The following code shows how to change the minimum date and time.
<!DOCTYPE html>
<html>
<body>
<!--from w w w.ja v a2 s. c o m-->
Date and time:
<input type="datetime" id="myDatetime" min="2000-01-01T22:57Z" max="2014-02-06T22:57Z">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myDatetime").min = "2009-02-01T21:57Z";
document.getElementById("demo").innerHTML = "changed";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the minimum date and time for a datetime field.
<!DOCTYPE html>
<html>
<body>
Enter a date and time between 2000-01-01 10:27 PM and 2014-04-06 10:57 PM:
<input type="datetime" id="myDatetime" min="2000-01-01T22:27Z" max="2014-04-06T22:57Z">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w .ja v a 2s.co m-->
var x = document.getElementById("myDatetime").min;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: