Question

I'm trying to change the default settings of Parsley so it matches the style formatting of Bootstrap 3.x.

I found this code snippet: https://gist.github.com/askehansen/6809825

I added this after the "Parsley.min.js" (using v2.0.0 by the way) file, but it seems not to be working at all. I use the DOM api only, not the regular js parsley() call.

What is the correct way to do this?

Thanks all.

Was it helpful?

Solution

Firstly, this gist is not anymore valid with 2.x versions. The default config is here: http://parsleyjs.org/doc/annotated-source/defaults.html

You could update above gist to make it works with new option config object, mainly, it would look to something similar to that:

  window.ParsleyConfig = {
    classHandler: function ( elem, isRadioOrCheckbox ) {
      // specify where parsley error-success classes are set
      return $(elem).parents(".form-group");
    },
    errorsWrapper: '<span class="help-block"></span>',
    errorTemplate: '<span></span>' 
   };

Secondly, you need to define window.ParsleyConfig before calling parsley.min.js

Please have a look to the documentation to understand how ParsleyConfig works and how you could use it to customize your whole Parsley behavior: http://parsleyjs.org/doc/index.html#psly-usage-global-configuration

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top