Get the maximum date and time allowed for a local datetime field:
var x = document.getElementById("myLocalDate").max;
Click the button to display the value of the max attribute of the local datetime field.
<!DOCTYPE html> <html> <body> Enter a date and time between 2000-10-06 22:22:55 and 2014-11-16 21:25:33: <input type="datetime-local" id="myLocalDate" min="2000-10-06T22:22:55" max="2014-11-16T21:25:33"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w w w . ja v a2 s . com*/ var x = document.getElementById("myLocalDate").max; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The max
property sets or gets the value of the max attribute of a local datetime field.
The max attribute specifies the maximum value of date and time for a local datetime field.
Data format:
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ss.ms | Specifies the maximum date and time allowed for the local datetime field. |
Components of the value:
The max
property returns a string representing the maximum date and time allowed.