title: jQuery Validate Credit Card Expiry Date in Rules addMethod Limit 20 Years in Future
body: <p>Hi I have some code on jquery validate rules validator.addMethod that allows the input to check for future date on card expiry date i.e. 10/2015 valid, what I would like to ask is there a way to add a limit of up to 20 years in the future, as at present they could enter card expiry date of 10/2099 or more. Thanks in advance!</p>
  
  <p>Here is the code I have, it also needs a custom message. Exceeds date range</p>
  
  <pre><code>&lt;input type="text" name="field_4"  id="field_4" value=""&gt;
  
  
  
   $.validator.addMethod(
          "Future",
          function (value, element) {
              var today = new Date();
              var startDate = new Date(today.getFullYear(),today.getMonth(),1,0,0,0,0);
              var expDate = value;
              var separatorIndex = expDate.indexOf('/');
              expDate = expDate.substr( 0, separatorIndex ) + '/1' + expDate.substr( separatorIndex );
              return Date.parse(startDate) &lt;= Date.parse(expDate);
          },
          "Must be a valid Expiry Date"
          );
  
          $(function() {
  
          $( "#Form" ).validate({
            rules: {    
              field_4: {
                  required: true,
                  Future: true,
                  minlength: 7
                  },
  </code></pre>