Using Parsley.js, is it possible to specify the element that should hold the error messages? I tried:
$('#myForm').parsley({
errors: {
container: {
$('#errorMessages')
}
}
});
But the error messages are still placed right after my form inputs.
@guillaumepotier I have try your code on jquerymobile and I do not show any error message display on screen. I want to add error-message to class "help-inline"
index.html
parsley.message.th.js
UPDATE - Working solution on v1.1.9-dev
I've added another data- attribute, data-parsley-errors-container="#element" that could allow you directly in dom to specify where the error messages will have to be displayed.
More info here: http://parsleyjs.org/doc/index.html#ui-for-field
Best
data-parsley-errors-container="#your-div-id"
worked for meJust define classHandler function before Parsley library import, in my case, i'm using bootstrap and it's to apply error and valid classes on parent div (it has "form-group" class).
Now just add data-parsley validate to your form tag :
When using bootstrap, you need to specify bootstrap error and valid classes too
In order to get the "has-error" class set on the parent div on invalid/error state (same for valid too):
This solution global to all fields.
I returned true from the function provided with container key.
My HTML Element
Javascript
It also works if I return
Hope this helps......
You'll need to use a callback function to do so
Here a simple example to attach error messages to element parent for example.
EDIT: Working on 1.1.10-dev, I changed the way to define the errors container like above. Careful, this is a BC Break;