@@ -35,6 +35,7 @@ define([
35
35
var checkoutConfig = window . checkoutConfig ,
36
36
validators = [ ] ,
37
37
observedElements = [ ] ,
38
+ postcodeElements = [ ] ,
38
39
postcodeElementName = 'postcode' ;
39
40
40
41
validators . push ( defaultValidator ) ;
@@ -78,11 +79,7 @@ define([
78
79
}
79
80
80
81
$ . each ( elements , function ( index , field ) {
81
- var elementBinding = self . doElementBinding . bind ( self ) ,
82
- fullPath = formPath + '.' + field ,
83
- func = uiRegistry . async ( fullPath ) ;
84
-
85
- func ( elementBinding ) ;
82
+ uiRegistry . async ( formPath + '.' + field ) ( self . doElementBinding . bind ( self ) ) ;
86
83
} ) ;
87
84
} ,
88
85
@@ -104,6 +101,7 @@ define([
104
101
105
102
if ( element . index === postcodeElementName ) {
106
103
this . bindHandler ( element , delay ) ;
104
+ postcodeElements . push ( element ) ;
107
105
}
108
106
} ,
109
107
@@ -138,7 +136,13 @@ define([
138
136
if ( ! formPopUpState . isVisible ( ) ) {
139
137
clearTimeout ( self . validateAddressTimeout ) ;
140
138
self . validateAddressTimeout = setTimeout ( function ( ) {
141
- self . postcodeValidation ( element ) ;
139
+ if ( element . index === postcodeElementName ) {
140
+ self . postcodeValidation ( element ) ;
141
+ } else {
142
+ $ . each ( postcodeElements , function ( index , elem ) {
143
+ self . postcodeValidation ( elem ) ;
144
+ } ) ;
145
+ }
142
146
self . validateFields ( ) ;
143
147
} , delay ) ;
144
148
}
@@ -151,7 +155,7 @@ define([
151
155
* @return {* }
152
156
*/
153
157
postcodeValidation : function ( postcodeElement ) {
154
- var countryId = $ ( 'select[name="country_id"]' ) . val ( ) ,
158
+ var countryId = $ ( 'select[name="country_id"]:visible ' ) . val ( ) ,
155
159
validationResult ,
156
160
warnMessage ;
157
161
0 commit comments