Previous date validation - Javascript Date Operation

Javascript examples for Date Operation:Date Validate

Description

Previous date validation

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 w  w w. j a  va  2s.c  om
var el = document.getElementById("mydate");
el.onchange = onChangeDate;
function onChangeDate(e){
    if(new Date(el.value) < new Date()){
        console.log("invalid date");
    }
}
    }

      </script> 
   </head> 
   <body> 
      <input type="date" id="mydate">  
   </body>
</html>

Related Tutorials