Input Time min Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time

Description

The min property sets or gets the min attribute of a time field, which sets the minimum time for a time field.

Tip: Use the min attribute together with the max attribute to create a range of legal values.

Tip: To set or return the value of the max attribute, use the max property.

The <input type="time"> element does not show as any time field in Firefox.

Set the min property with the following Values

Value Description
hh:mm:ss.ms Sets the minimum time allowed for the time field.
  • hh - hour (e.g. 22 for 10.00pm)
  • mm - minutes (e.g. 30)
  • ss - seconds (e.g. 03)
  • ms - milliseconds (e.g 20)
  • For Examples: "09:55:33.55", "22:15:35" or "16:00".

Return Value

A String, representing the minimum time allowed for the time field

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Time: <input type="time" id="myTime" min="20:00" max="22:00">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  www  .  j ava  2  s  .c o  m*/
    var x = document.getElementById("myTime").min;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials