The max
property sets or gets the value of the max attribute of a local datetime field.
The max
attribute specifies the maximum value for a local datetime field.
max |
Yes | No | No | Yes | Yes |
Return the max property.
var v = datetimelocalObject.max
Set the max property.
datetimelocalObject.max=YYYY-MM-DDThh:mm:ss.ms
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ss.ms | Set the maximum date and time for the local 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 w w . ja v a2 s . c o m-->
Date and time:
<input type="datetime-local" id="myLocalDate" min="2000-10-06T22:22:55" max="2014-11-16T21:25:33">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myLocalDate").max = "2012-01-01T22:22:55";
document.getElementById("demo").innerHTML = "";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the maximum date and time for a local datetime field.
<!DOCTYPE html>
<html>
<body>
<!-- ww w.jav a 2 s. co m-->
Enter a date and time between 2000-10-06 12:22:55 and 2014-10-16 12:25:33:
<input type="datetime-local" id="myLocalDate" min="2000-10-06T12:22:55" max="2014-10-16T12:25:33">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myLocalDate").max;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: