summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epirts.js16
1 files changed, 16 insertions, 0 deletions
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) {