Javascript examples for DOM HTML Element:Input Date
Calculate Age from HTML input date type using getFullYear() method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www.j a va 2s . co m var today=new Date(); var dob=new Date("1/1/2000"); var age=today.getFullYear()-dob.getFullYear(); document.getElementById("age").value=age; } </script> </head> <body> <input type="text" id="age"> </body> </html>