문제

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.

도움이 되었습니까?

해결책

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>'
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top