Get the minimum date allowed for a date field:
var x = document.getElementById("myDate").min;
Click the button to display the value of the min attribute of the date field.
<!DOCTYPE html> <html> <body> Enter a date between 1980-01-01 and 2000-01-01: <input type="date" id="myDate" name="bday" min="1980-01-01" max="2000-01-01"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w.j a va 2s . c o m var x = document.getElementById("myDate").min; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The min
property sets or gets the value of the min attribute of a date field.
The min attribute sets the minimum date value for a date field.
The min
property accepts and returns a String type value.
Property value format
Value | Description |
---|---|
YYYY-MM-DD | Specifies the minimum date allowed for the date field. YYYY - year (e.g. 2020) MM - month (e.g. 01 for January) DD - day of the month (e.g. 08) |
For example: "2020-02-09" means February 9th, 2014.