title: AngularJS - Credit Card Expiration date format to validate form
body: <p>I am learning AngularJS, and I am making a credit card validator. 
  I have implemented the Luhn Algorithm in a custom filter and it works perfectly. However, in order to validate the form I want also the expiration date to be valid, ie to fulfill these conditions:
  - 08/16
  - 02/2015
  - 0518
  - the date shall not be expired (obviously)</p>
  
  <p>So since I found out there was already date filter in Angular, I tried to create one. To me it seems logical, but it does not work at all. Here's the code:</p>
  
  <pre><code>/**
  * validate-expiry-date Module
  *
  * Validates the date format and that the date is not in the past
  */
  angular.module('validate-expiry-date', []).filter('validDate', [function () {
    return function (date) {
  
      var actualDate = new Date();
      var m,y,d;
  
      if (/^\d{2}\/\d{2}$/.test(date)) {
          m = date.substring(0, 2);
          y = 20 + date.slice(-2);
          d = new Date(y,m);
          return(actualDate &gt; d);
      }if (/^\d{2}\/\d{4}$/.test(date)) {
          m = date.substring(0, 2);
          y = date.slice(-4);
          d = new Date(y,m);
          return(actualDate &gt; d);
      }else if (/^\d{4}$/.test(date)) {
          m = date.substring(0, 2);
          y = 20 + date.slice(-2);
          d = new Date(y,m);
          return(actualDate &gt; d);
      };
    }
  }])
  </code></pre>
  
  <p>Anyone could explain me what's going on ?
  Thanks,
  B.</p>