Input Time max Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Time


The max property sets or gets the max attribute of a time field, which sets the maximum value (time) for a time field.

Set the max property with the following Values

Value Description Sets 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)
  • For Examples: "09:55:33.55", "22:15:35" or "16:00".

Return Value

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

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

Demo Code

ResultView the demo in separate window

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

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

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

function myFunction() {/*from  www  . j  a v a 2s.  com*/
    var x = document.getElementById("myTime").max;
    document.getElementById("demo").innerHTML = x;


Related Tutorials