summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-25 22:21:04 -0500
committerJules Laplace <jules@okfoc.us>2015-11-25 22:21:04 -0500
commit98e21c4f1b096fc117a6a0f770bb69ab7c83914d (patch)
tree00b5d074b011fc26084b37dd662e4fc95f75c492 /StoneIsland/www/js/lib
parentec87912a5ca1c0d6862b07012fdbbdf2d4b4f86a (diff)
validate cc number
Diffstat (limited to 'StoneIsland/www/js/lib')
-rw-r--r--StoneIsland/www/js/lib/nav/CreditCardView.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/StoneIsland/www/js/lib/nav/CreditCardView.js b/StoneIsland/www/js/lib/nav/CreditCardView.js
index eaab7086..8d805b80 100644
--- a/StoneIsland/www/js/lib/nav/CreditCardView.js
+++ b/StoneIsland/www/js/lib/nav/CreditCardView.js
@@ -3,13 +3,21 @@ var CreditCardView = View.extend({
template: $("#creditcard_template").html(),
+ cardOptions: {
+ accept: ['visa', 'mastercard', 'amex'],
+ },
+
events: {
},
initialize: function(opt){
this.parent = opt.parent
this.setElement( this.parent.$(".cc") )
- this.parent.$(".cc").html(this.template)
+ this.$el.html(this.template)
+
+ this.$number = this.$("[name=Number]")
+ console.log(this.$number)
+ this.$number.validateCreditCard(this.updateCard.bind(this), this.cardOptions)
},
populate: function(data){
@@ -18,15 +26,26 @@ var CreditCardView = View.extend({
this.load_data(data)
},
+ updateCard: function(card){
+ console.log(card)
+ // card.card_type.name
+ // card.card_type.valid
+ },
+
validate_presence: {
'Number': 'Please enter your credit card number.',
'CVV': 'Please enter your security code.',
},
validate_fields: function(data, errors){
+
+ var card = this.$number.validateCreditCard(this.cardOptions)
+
+ if (! card.valid) { errors.push([ "Number", "Your card number is invalid." ])
if (! data.ExpirationMonth || data.ExpirationMonth == "NONE") { errors.push([ "ExpirationMonth", "Please enter the expiration month." ]) }
if (! data.ExpirationYear || data.ExpirationYear == "NONE") { errors.push([ "ExpirationYear", "Please select the expiration month." ]) }
data.UserId = auth.user_id
+
},
})