
(function(){
  document.addEventListener('DOMContentLoaded', function(){
    var d = new Date();
    d.setFullYear(d.getFullYear() + 15);
    var max = d.toISOString().slice(0,10);

    document.querySelectorAll('input[name*="expiry"], input[id*="expiry"], input[name*="expire"], input[id*="expire"]').forEach(function(el){
      el.type = 'date';
      el.max = max;
      if(!el.value || el.value === '0000-00-00' || el.value === '2099-12-31'){
        el.value = max;
      }
    });
  });
})();
