Disable HTML5 input type date element before today - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Date

Description

Disable HTML5 input type date element before today

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from ww  w . j  a  va2s. c  o  m
var today = new Date().toISOString().split('T')[0];
document.getElementsByName("setTodaysDate")[0].setAttribute('min', today);
    }

      </script> 
   </head> 
   <body> 
      <input name="setTodaysDate" type="date">  
   </body>
</html>

Related Tutorials