|
53 | 53 | }, |
54 | 54 | dependingOnValueChanged = function() { |
55 | 55 | var $input = $(this), |
56 | | - $otherInput = this.$dependingInput, |
57 | | - valueOfDependingInput = $.formUtils.getValue($input), |
58 | | - requiredValueOfDependingInput = $input.valAttr('depending-value'), |
59 | | - otherInputHasValue = $.formUtils.getValue($otherInput) ? true:false, |
60 | | - dependingInputIsMissingValueOrHasIncorrectValue = !valueOfDependingInput || ( |
61 | | - requiredValueOfDependingInput && |
62 | | - requiredValueOfDependingInput !== valueOfDependingInput |
63 | | - ); |
64 | | - |
65 | | - if (dependingInputIsMissingValueOrHasIncorrectValue && !otherInputHasValue) { |
66 | | - $.formUtils.dialogs.removeInputStylingAndMessage($otherInput, conf); |
67 | | - } |
| 56 | + inputValue = $.formUtils.getValue($input), |
| 57 | + requiredValueOfDependingInput = $input.valAttr('depending-value'); |
| 58 | + $.each(this.dependingInputs, function (i, $otherInput) { |
| 59 | + var otherInputHasValue = $.formUtils.getValue($otherInput) ? true:false, |
| 60 | + dependingInputIsMissingValueOrHasIncorrectValue = !inputValue || ( |
| 61 | + requiredValueOfDependingInput && |
| 62 | + requiredValueOfDependingInput !== inputValue |
| 63 | + ); |
| 64 | + |
| 65 | + if (dependingInputIsMissingValueOrHasIncorrectValue && !otherInputHasValue) { |
| 66 | + $.formUtils.dialogs.removeInputStylingAndMessage($otherInput, conf); |
| 67 | + } |
| 68 | + }); |
68 | 69 | }; |
69 | 70 |
|
70 | 71 | $form.find('[data-validation-depends-on]') |
|
79 | 80 | .on('change', dependingOnValueChanged) |
80 | 81 | .valAttr('depending-value', $dependingInput.valAttr('depends-on-value')); |
81 | 82 |
|
82 | | - this.$dependingInput = $dependingInput; |
83 | | - |
| 83 | + this.dependingInputs = this.dependingInputs || []; |
| 84 | + this.dependingInputs.push($dependingInput); |
84 | 85 | }); |
85 | | - |
86 | 86 | }); |
87 | 87 |
|
88 | 88 | }, |
|
0 commit comments