HTML DOM Input Time min Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Input Time min property returns/sets min attribute of Input Time.

Syntax

Following is the syntax −

  • Returning string value
inputTimeObject.min
  • Setting max to string value
inputTimeObject.min = hh:mm:ss.ms

String Values

Here, “hh:mm:ss.ms” can be the following −

stringValueDetails
hhIt defines hour (eg:18)
mmIt defines minutes (eg:59)
ssIt defines seconds (eg:00)
msIt defines milli-seconds (eg:700)

Example

Let us see an example of Input Time min property −

<!DOCTYPE html>
<html>
<head>
<title>Input Time min</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form>
<fieldset>
<legend>Time-min</legend>
<label for="TimeSelect">Time Elapsed:
<input type="time" id="TimeSelect" value="00:00:00" min="01:30:00">
</label>
<input type="button" onclick="getElapsedTime()" value="Confirm">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputTime = document.getElementById("TimeSelect");
   divDisplay.textContent = 'Minimum wait time: '+inputTime.min;
   function getElapsedTime() {
      if(inputTime.value >= inputTime.min)
         divDisplay.textContent = 'You can leave exam hall now, as you have waited for: '+inputTime.value;
      else
         divDisplay.textContent = 'You cannot leave exam hall before: '+inputTime.min;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Confirm’ button −

After clicking ‘Confirm’ button with invalid time field −

After clicking ‘Confirm’ button with valid time field −

raja
Updated on 30-Jul-2019 22:30:26

Advertisements