Parsley validation and succes

I try to make CSS not only for an error message but also success message.
If I set a code it will not work myalertsuccess1 class. Is this wrong coded or some settings prevent this option?

<script>
$(function()
 {

  var parsleyConfig = {
  errorsContainer: function(pEle) {
    var $err = pEle.$element.siblings('.myMessageCLASS');
    errorClass: 'alert alert-error'
    successClass: 'alert myalertsuccess1'
    console.log($err);
    return $err;
   }
  }

  var $parsley = $('#myformID').parsley(parsleyConfig);
 }
)
</script>

You’ve put your errorClass and successClass properties inside the errorsContainer function; they dont belong there, they’re part of the parsley config.

  var parsleyConfig = {
    errorClass: 'alert alert-error',
    successClass: 'alert myalertsuccess1',
    errorsContainer: function(pEle) {
      var $err = pEle.$element.siblings('.myMessageCLASS');
      console.log($err);
      return $err;
    }
  }
1 Like

I’m not sure but it is working

   errorClass: 'alert alert-error',

even inside the errorsContainer function as it is related to .myMessageCLASS. If I set inside config it works like global value, but I need only inside .myMessageCLASS also SUCCESS CLASS.

Well it shouldnt, because what you posted before was not valid javascript.

IMHO it is the correct code as you can place custom error message related to ID myformID but success CLASS will not work. Do you have the whole code to test Parsley validation based on SUCCESS CLASS and custom error message box?

var $parsley = $('#myformID').parsley(parsleyConfig);

Well your HO can be wrong about Javascript syntax all it wants. You stuck a property syntax in the middle of a function and say it works. Except it doesn’t, because you’re here asking the question, and when told that it doesnt work because the syntax is wrong, tell the person helping you that they’re wrong.

I wish you the best in sorting this out, and the best of luck to whoever wants to try.

Thnak you for the message.

I have seen a script from the following URL:

It uses JS change error container. I try to make it also with the modified success class.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.