HTML DOM Input DatetimeLocal min Property

HTMLWeb DevelopmentFront End Technology

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

Syntax

Following is the syntax −

  • Returning string value
inputDatetimeLocalObject.min
  • Setting min to string value
inputDatetimeLocalObject.min = YYYY-MM-DDThh:mm:ss

String Values

Here, “YYYY-MM-DDThh:mm:ss” can be the following −

stringValueDetails
YYYYIt defines year (eg:199)
MMIt defines month (eg: 07 for July)
DDIt defines Day (eg: 11)
TIt is a separator for date and time
hhIt defines hour (eg:08)
mmIt defines minutes (eg:18)
ssIt defines seconds (eg:23)

Example

Let us see an example of Input DatetimeLocal min property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal 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>Datetime-Local-min</legend>
<label for="datetimeLocalSelect">Today :
<input type="datetime-local" id="datetimeLocalSelect" value="2019-05-23T12:45" min="2000-03-1T10:23">
</label>
<input type="button" onclick="getMinimum()" value="What's the minimum input? ">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
   function getMinimum() {
      divDisplay.textContent = 'Minimum Legal Input: '+inputDatetimeLocal.min;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘What’s the minimum input? ’ button −

After clicking ‘What’s the minimum input? ’ button −

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

Advertisements