Javascript DOM HTML Input Time min Property get

Introduction

Get the minimum time allowed for a time field:

var x = document.getElementById("myTime").min;

Click the button to display the value of the min attribute of the time field.

View 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() {//from  www .  j  a v  a  2 s.  co m
  var x = document.getElementById("myTime").min;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

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

The <input type="time"> element is not supported in Firefox.

The min property accepts and returns a String type value.

Value
Description
hh:mm:ss.ms





Specifies 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)
Examples: "09:55:32.55", "22:15:35" or "16:00".

The min property returns a String representing the minimum time allowed for the time field.




PreviousNext

Related