@@ -230,19 +230,19 @@ var Validator = function () {
230
230
Validator . prototype . different = function ( otherName ) {
231
231
this . otherName = otherName ;
232
232
this . triggerOtherName ( otherName ) ;
233
- var otherValue = this . $form . serializeArrayKv ( ) [ otherName ] ;
233
+ var otherValue = this . serializeArrayKv ( this . $form ) [ otherName ] ;
234
234
return this . val !== otherValue ;
235
235
} ;
236
236
Validator . prototype . required_if = function ( otherName ) {
237
237
this . otherName = otherName ;
238
238
this . triggerOtherName ( otherName ) ;
239
- var otherValue = this . $form . serializeArrayKv ( ) [ otherName ] ;
239
+ var otherValue = this . serializeArrayKv ( this . $form ) [ otherName ] ;
240
240
return otherValue ? this . required ( ) : true ;
241
241
} ;
242
242
Validator . prototype . required_if_val = function ( otherName , specificValue ) {
243
243
this . otherName = otherName ;
244
244
this . triggerOtherName ( otherName ) ;
245
- var otherValue = this . $form . serializeArrayKv ( ) [ otherName ] ;
245
+ var otherValue = this . serializeArrayKv ( this . $form ) [ otherName ] ;
246
246
if ( this . valLength ( specificValue ) && otherValue === specificValue ) {
247
247
// checked value === other value
248
248
return this . required ( ) ;
@@ -322,7 +322,12 @@ var Validator = function () {
322
322
} ) ;
323
323
return message ;
324
324
} ;
325
-
325
+ Validator . prototype . serializeArrayKv = function ( $form ) {
326
+ var arr = $form . serializeArray ( ) , obj = { } ;
327
+ for ( var i = 0 ; i < arr . length ; ++ i )
328
+ obj [ arr [ i ] . name ] = arr [ i ] . value ;
329
+ return obj ;
330
+ } ;
326
331
Validator . prototype . language = {
327
332
numeric : 'The {label} must be a number.' ,
328
333
integer : 'The {label} must be an integer.' ,
@@ -344,7 +349,7 @@ var Validator = function () {
344
349
in : 'The selected {label} is invalid.' ,
345
350
not_in : 'The selected {label} is invalid.' ,
346
351
different : 'The {label} and {otherLabel} must be different.' ,
347
- required : 'The {label} field is required.. ' ,
352
+ required : 'The {label} field is required.' ,
348
353
required_if : 'The {label} field is required when {otherLabel} is filled.' ,
349
354
required_if_val : 'The {label} field is required when {otherLabel} is {param0}' ,
350
355
same : 'The {label} and {otherLabel} must match.' ,
0 commit comments