summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/nav
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-25 21:55:29 -0500
committerJules Laplace <jules@okfoc.us>2015-11-25 21:55:29 -0500
commit704bffcd1d1d49bbb00241b96bacf22e5a750f26 (patch)
treef9a4d03c209b9d857abdb85a1b4fdb9008ffb5bd /StoneIsland/www/js/lib/nav
parent99c8ec608ee83526ce9e0df2854666920735eda5 (diff)
addresses adding properly
Diffstat (limited to 'StoneIsland/www/js/lib/nav')
-rw-r--r--StoneIsland/www/js/lib/nav/AddressView.js7
-rw-r--r--StoneIsland/www/js/lib/nav/CreditCardView.js11
2 files changed, 10 insertions, 8 deletions
diff --git a/StoneIsland/www/js/lib/nav/AddressView.js b/StoneIsland/www/js/lib/nav/AddressView.js
index fb30062e..9d4a97b9 100644
--- a/StoneIsland/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/www/js/lib/nav/AddressView.js
@@ -18,9 +18,7 @@ var AddressView = SerializableView.extend({
data.Address1 = address[0]
data.Address2 = address[1]
this.$(".address input").val("")
- Object.keys(data).forEach(function(key){
- this.$(".address [name=" + key + "]").val(data[key])
- }.bind(this))
+ this.load_data(data)
},
validate_presence: {
@@ -33,12 +31,11 @@ var AddressView = SerializableView.extend({
validate_fields: function(data, errors){
if (data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) }
- if (data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) }
+ if (! data.Province || data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) }
data.Address = data.Address1 + "\n" + data.Address2
data.UserId = auth.user_id
delete data.Address1
delete data.Address2
- console.log(errors)
},
})
diff --git a/StoneIsland/www/js/lib/nav/CreditCardView.js b/StoneIsland/www/js/lib/nav/CreditCardView.js
index 33ecab79..eaab7086 100644
--- a/StoneIsland/www/js/lib/nav/CreditCardView.js
+++ b/StoneIsland/www/js/lib/nav/CreditCardView.js
@@ -8,20 +8,25 @@ var CreditCardView = View.extend({
initialize: function(opt){
this.parent = opt.parent
+ this.setElement( this.parent.$(".cc") )
this.parent.$(".cc").html(this.template)
},
populate: function(data){
this.parent.$(".cc input").val("")
- Object.keys(data).forEach(function(key){
- this.parent$(".cc [name=" + key + "]").val(data[key])
- }.bind(this))
+ this.$(".cc input").val("")
+ this.load_data(data)
},
validate_presence: {
+ 'Number': 'Please enter your credit card number.',
+ 'CVV': 'Please enter your security code.',
},
validate_fields: function(data, errors){
+ 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
},
})