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