Javascript Reference - HTML DOM Input Time min Property








The min property sets or gets the min attribute of a time field.

The min attribute specifies the minimum time for a time field.

Browser Support

min Yes No No Yes Yes

Syntax

Return the min property.

var v = timeObject.min

Set the min property.

timeObject.min=hh:mm:ss.ms




Property Values

Value Description
hh:mm:ss.ms Set the minimum time allowed for the time field.
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 31)
  • ss - seconds (e.g. 01)
  • ms - milliseconds (e.g 21)

Return Value

A String type value representing the minimum time allowed for the time field.

Example

The following code shows how to change the minimum value.


<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime" min="20:00" max="22:00">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from w  w w.ja  va  2s.com-->
    var x = document.getElementById("myTime").min = "16:00";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get the minimum time allowed for a time field.


<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime" min="20:00" max="22:00">
<button onclick="myFunction()">test</button>
<!--from w ww . j a  v a2  s  .c om-->
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myTime").min;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: