summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-03-15 23:19:49 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-03-15 23:19:49 (EDT)
commit209c195d5b94de50ef5b727a1294b5130b7d46fa (patch)
treefae245f442ff28b883e52b006d124a8902e3b586
parent64d0446f24411746424c4a9f004ace7238c2d3fe (diff)
downloadepirts.js-209c195d5b94de50ef5b727a1294b5130b7d46fa.zip
epirts.js-209c195d5b94de50ef5b727a1294b5130b7d46fa.tar.gz
epirts.js-209c195d5b94de50ef5b727a1294b5130b7d46fa.tar.bz2
Epirts.card.validateExpiry(): Implement
-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) {