Javascript DOM HTML Input Time max Property set

Introduction

Change the maximum time allowed:

document.getElementById("myTime").max = "23:00";

Click the button to change 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.jav  a 2  s. c om*/
  var x = document.getElementById("myTime").max = "23:00";
  document.getElementById("demo").innerHTML = "The value of the max attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related