Question

I have a form that does not include the data-parsley-validate attribute so it is not made a Parsley form before calling the .parsley() function as shown below.

I also have this JavaScript that initializes Parsley with my form:

$('#reg-form').parsley({
  successClass: 'success',
  errorClass: 'error',
  errors: {
     errorsWrapper: '<span class=\"help-block\"></span>',
     errorElem: '<span></span>'
  }

});

However, if I fill out the form so it isn't valid, the error messages still show up in the default ul list, and my success and error classes are not used.

I have a lot of form elements in this form, so instead of using the DOM API, I'd like to use JavaScript to override that option for every form element.

I'm using Parsley 2.0.0-rc4 with jQuery 2.0.3.

Était-ce utile?

La solution

Silly mistake on my part. The errors options don't belong in the errors key. The example I worked from was wrong or outdated.

Working example:

$('#reg-form').parsley({
  successClass: 'success',
  errorClass: 'error',
  errorsWrapper: '<span class=\"help-block\"></span>',
  errorElem: '<span></span>'
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top