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