Created
April 26, 2016 19:34
-
-
Save sdurandeu/2971d83d194203ac571f6c25cd2ff2fa to your computer and use it in GitHub Desktop.
Validate credit card expiration with moment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this code assumes a credit card is valid in the current month | |
var validateDate = function () { | |
var creditCardDate = moment($scope.data.expirationYear+$scope.data.expirationMonth, "YYMM"); | |
var today = moment(); | |
return creditCardDate.isValid() && (today < creditCardDate.add(1, 'months')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment