Maximum Year in Expiry Date of Credit Card

前端 未结 10 891
情话喂你
情话喂你 2021-01-30 02:30

Various online services have different values for maximum year of expiry, when it comes to Credit Cards.

For instance:

  • Basecamp: +15 years (2025)
10条回答
  •  梦谈多话
    2021-01-30 03:25

    Here is a Javascript code snippet you can use to display a customizable list of upcoming years for CC validation:

        var yearsToShow = 20;
        var thisYear = (new Date()).getFullYear();
        for (var y = thisYear; y < thisYear + yearsToShow; y++) {
          var yearOption = document.createElement("option");
          yearOption.value = y;
          yearOption.text = y;
          document.getElementById("expYear").appendChild(yearOption);
        }
              
              
                
                
              

提交回复
热议问题