summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StoneIsland/www/index.html2
-rw-r--r--StoneIsland/www/js/lib/nav/CreditCardView.js21
-rw-r--r--StoneIsland/www/js/vendor/jquery.creditCardValidator.js3
3 files changed, 23 insertions, 3 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html
index fad265e2..4d920e10 100644
--- a/StoneIsland/www/index.html
+++ b/StoneIsland/www/index.html
@@ -732,7 +732,7 @@
</div>
<script type="text/html" id="creditcard_template">
- <input type="text" name="Number" placeholder="CREDIT CARD NUMBER" required>
+ <input type="number" name="Number" placeholder="CREDIT CARD NUMBER" required>
<div class="half-input">
<div class="select-wrapper">
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
+
},
})
diff --git a/StoneIsland/www/js/vendor/jquery.creditCardValidator.js b/StoneIsland/www/js/vendor/jquery.creditCardValidator.js
index a9117abe..3ec39f27 100644
--- a/StoneIsland/www/js/vendor/jquery.creditCardValidator.js
+++ b/StoneIsland/www/js/vendor/jquery.creditCardValidator.js
@@ -181,11 +181,12 @@ IN THE SOFTWARE.
return function() {
var number;
number = normalize($(_this).val());
+ console.log(number)
return validate_number(number);
};
})(this);
normalize = function(number) {
- return number.replace(/[ -]/g, '');
+ return (number || "").replace(/[ -]/g, '');
};
if (!bind) {
return validate();