Javascript examples for DOM HTML Element:Input Date
The max property sets or gets the max attribute of a date field, which controls the maximum date for a date field.
Set the max property with the following Values
Value | Description |
---|---|
YYYY-MM-DD | Sets the maximum date allowed for the date field. |
An example: "2018-02-09" means February 9th, 2018 (09/02/2018).
A String, representing the maximum date allowed
The following code shows how to get the maximum date allowed for a date field:
<!DOCTYPE html> <html> <body> Date://from w w w . j av a 2 s. c om <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() { var x = document.getElementById("myDate").max = "2018-01-01"; document.getElementById("demo").innerHTML = "changed from '2000-01-01' to '2018-01-01'."; } </script> </body> </html>