Javascript examples for DOM HTML Element:Input Date
The value property sets or gets the value attribute of a date field, which sets a date for the date field.
Set the value property with the following Values
Value | Description |
---|---|
YYYY-MM-DD | Sets a date for the date field. |
An example: "2018-02-09" means February 9th, 2018 (09/02/2018).
A String, representing the date of the date field
The following code shows how to Set a date for a date field:
<!DOCTYPE html> <html> <body> <input type="date" id="myDate" value="2000-05-05"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w ww . j a v a 2 s . c o m*/ document.getElementById("myDate").value = '2001-01-01'; var x = document.getElementById("myDate").value; document.getElementById("demo").innerHTML = x; } </script> </body> </html>