I am currently using clientside_validation with clientside_validation_states to validate conditionally required fields.

The issue I am experiencing is when the conditionally required element is invalid (empty), it is showing the generic "This field is required" (from jQuery.validation defaults) instead of using a message that is typically seen (and shows on all other, non-conditionally required fields) - for example, "First Name field is required".

I am using a custom errorPlacement method, but I'm not sure that it matters:

    // custom error placement
    Drupal.clientsideValidation.prototype.replaceLabel = function (error, element)  {
      var label, origLabel;
      var wrapperClass = 'formReplacedLabel';
      var WrapperEl = 'span';
      label = element.siblings('label');
      if (label.find('.form-replaced-label').length === 0) {
        label.wrapInner("<span class='form-replaced-label'></span>");

So, the error being passed (for the states dependent control) to the custom errorPlacement method is just the default $.validator.messages.required instead of what is passed for the other controls. I can't just change .messages.required to something that is for this field specifically either, as I have several forms with state dependent fields.

I have attached an animated gif that I think can explain the issue better than I do.

enter image description here


1 Answer 1


Turns out this is a bug. The hot fix is to add the $message argument to the _clientside_validation_set_equal() call on clientside_validation_fapi.module. So that it looks like: _clientside_validation_set_equal($name, $title, $params[0], $js_rules, $message);.

I've started an issue and submitted a patch https://drupal.org/node/2140163

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.