Javascript DOM HTML Input Time max Property get

Introduction

Get the maximum time allowed for a time field:

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

Click the button to display the value of the max 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  w ww  .j ava  2 s  .  c o m
  var x = document.getElementById("myTime").max;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

The max attribute specifies the maximum time for a time field.

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

The max property accepts and returns a String type value.

Value
Description
hh:mm:ss.ms







Specifies the maximum 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 max property returns a String representing the maximum time allowed for the time field.




PreviousNext

Related