1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
var AddressView = SerializableView.extend({
template: $("#address_template").html(),
events: {
},
initialize: function(opt){
this.parent = opt.parent
this.$el = this.parent.$(".address")
this.el = this.$el[0]
this.$el.html(this.template)
},
populate: function(data){
this.parent.$(".address input").val("")
Object.keys(data).forEach(function(key){
this.parent$(".address [name=" + key + "]").val(data[key])
}.bind(this))
},
deserialize: function(){
},
validate_presence: {
"Name": "Please enter your first name.",
"Surname": "Please enter your last name.",
"Address1": "Please enter your street address.",
"City": "Please enter your city.",
"State": "Please choose your state.",
"Phone": "Please enter your phone number.",
},
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." ]) }
},
})
|