Parsley.js error message
Asked Answered
P

1

3

I am using parsley.js from http://parsleyjs.org/. Wanted to get the error message from the call back function (onFieldError) and place the value inside a twitter bootstrap popover. In order to do so, I'll need to place it inside the data-content attribute of the popover instead of a div. Can any one tell me how to do this or fix this.

onFieldError: function ( elem, constraints, ParsleyField ) {}

These are the only parameters that are available.

Pneumonia answered 4/6, 2013 at 8:56 Comment(0)
F
1

If you look in parsley.js source file, you'll see that there is an errors object config at the bottom of the file that allows you to have control over where you want to put your error messages. Let take a look at it:

// specify where parsley error-success classes are set
errors: {
    classHandler: function ( elem, isRadioOrCheckbox ) {}
  , container: function ( elem, isRadioOrCheckbox ) {}
  , errorsWrapper: '<ul></ul>'
  , errorElem: '<li></li>'
}

errors.classHander is the dom element that would receive parsley-success and parsley-error classes. errors.container is the dom element where would be appended the error element -> basically, it should be here your popover dom element errors.errorsWrapper and errors.errorElem would allow you to customize deeper the error template (by default, ul and lis)

Hope that would help you

Best

Fawne answered 19/9, 2013 at 15:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.