From 209c195d5b94de50ef5b727a1294b5130b7d46fa Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Sun, 15 Mar 2015 23:19:49 -0400 Subject: Epirts.card.validateExpiry(): Implement --- diff --git a/epirts.js b/epirts.js index c7d4712..1e03ef4 100644 --- a/epirts.js +++ b/epirts.js @@ -81,6 +81,22 @@ var Stripe = Epirts = (function() { }; pub.validateExpiry = function(month, year) { + var today; + + today = new Date(); + month = parseInt(month, 10); + year = parseInt(year, 10); + if (isNaN(month) || isNaN(year)) { + return false; + } else if (month < 1 || month > 12) { + return false; + } else if (year < today.getFullYear()) { + return false; + } else if (year === today.getFullYear() && + month <= today.getMonth()) { + return false; + } + return true; }; pub.validateCVC = function(cvc) { -- cgit v0.9.1