Compare date value and check valid Date value - Javascript Date Operation

Javascript examples for Date Operation:Date Compare

Description

Compare date value and check valid Date value

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input onchange="onChange(this)"> 
      <script type="text/javascript">
var date = '2013-03-12';
var my = new Date(date);//from w  ww. ja  v  a 2s .co m
function onChange(el){
    var user_date = el.value;
    var udate = new Date(user_date);
    if(isNaN(udate.getTime()) || udate < my){
        console.log('less')
    }
}

      </script>  
   </body>
</html>

Related Tutorials