Javascript examples for DOM HTML Element:Input Date
Print date in input date box in html
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function displayDate() {/*from w ww . j a v a 2 s . c o m*/ var now = new Date(); var day = ("0" + now.getDate()).slice(-2); var month = ("0" + (now.getMonth() + 1)).slice(-2); var today = now.getFullYear() + "-" + (month) + "-" + (day); document.getElementById("fname").value = today; } </script> </head> <body onload="displayDate()"> Enter date: <input type="date" id="fname" readonly> </body> </html>