I want to alter the positioning of each error message. That is display the error message in the respective . By using th
Parsley API has been updated. The current method is:
data-parsley-errors-container="#your-div-id"
See documentation here: http://parsleyjs.org/doc/index.html#psly-ui-for-field
You can do this by overwriting Parsley's default options. (note: I'm talking about the latest version [v2.0], which I suggest you use) You basically want to give Parsley a method that will find the .errorBlock
container based on the input field. It would look something like this:
var parsleyConfig = {
errorsContainer: function(pEle) {
var $err = pEle.$element.siblings('.errorBlock');
return $err;
}
}
$('#yourFormID').parsley(parsleyConfig);
And here's a live example.
Note: using this method you can't use the parsley-validate
attribute that Makrand suggests. Calling .parsley
on your form does the same thing, except you can add your custom options to it. Also, you need to prefix all of your parsley attributes with data-
, because they're data attributes (as of v2.0).
try this:
data-parsley-errors-container=".errorBlock"
You can check this attribute in Parsley Documentation
In reference to @ahmad hussain's answer you also need to put an attribute in your form:
<form parsley-validate>