Validation for academic year like 2015-16 - Javascript Date Operation

Javascript examples for Date Operation:Year

Description

Validation for academic year like 2015-16

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  .java 2s. com*/
var regex = /^2\d{3}-[1-9]{2}$/;
var year = "2011-12";
var years = year.split("-").map(function(el){
   return parseInt(el)
})
console.log(years[0]>=years[1] + 2000);
console.log(regex.test("2011-12"))
    }

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

Related Tutorials