diff --git a/js/clientside_validation.js b/js/clientside_validation.js index 44b972c..ef33a86 100644 --- a/js/clientside_validation.js +++ b/js/clientside_validation.js @@ -258,6 +258,11 @@ // Default behavior $element.removeClass(errorClass).addClass(validClass); + // Handle unhighlighting for chosen Drupal module + if ($element.hasClass('chosen-processed')) { + $element.siblings('div.chosen-container').removeClass(errorClass).addClass(validClass); + } + // Sort the classes out for the tabs - we only want to remove the // highlight if there are no inputs with errors... var $fieldset = $element.parents('fieldset.vertical-tabs-pane'); @@ -282,6 +287,11 @@ // Default behavior $element.addClass(errorClass).removeClass(validClass); + // Handle highlighting for chosen Drupal module + if ($element.hasClass('chosen-processed')) { + $element.siblings('div.chosen-container').addClass(errorClass).removeClass(validClass); + } + // Sort the classes out for the tabs var $tab = self.findVerticalTab($element); if ($tab) { @@ -362,6 +372,12 @@ } } + // Trigger click event for chosen elements processed by Drupal chosen module + // This will allow the error message on the page to hide/show + $('.chosen-processed').change(function () { + $(this).trigger('click'); + }); + /** * Notify that the form contains errors. * @event clientsideValidationFormHasErrors @@ -531,7 +547,8 @@ } if (!self.settings.includeHidden) { - validate_options.ignore = ':input:hidden'; + // By default, only ignore hidden elements not processed by chosen Drupal module + validate_options.ignore = ':input:hidden:not(.chosen-processed)'; } else { validate_options.ignore = ''; @@ -542,7 +559,8 @@ } } else { - validate_options.ignore += ', .horizontal-tab-hidden :input'; + // Patch found at https://www.drupal.org/project/clientside_validation/issues/2293259#comment-11287885 + validate_options.ignore += (validate_options.ignore == '') ? '.horizontal-tab-hidden :input' : ', .horizontal-tab-hidden :input'; } //Since we can only give boolean false to onsubmit, onfocusout and onkeyup, we need //a lot of if's (boolean true can not be passed to these properties).