Question

How to bind parsley.js v2.0.0-rc2 to non form element (e.g div) and change default errors container from js? In my case I need errors to be below validated element parent.

Était-ce utile?

La solution

1) If you want to bind inputs grouped inside a div, simply add data-parsley-validate on the div. It would be considered as a Form with its fields inside.

2) Regarding errors messages, you could leverage this config function like that:

<script type="text/javascript">
    window.ParsleyConfig = {
        errorsContainer: function (parsleyField) {
            return parsleyField.$element.parent().parent();
        }
    };
</script>

Placed before calling parsley.js would tell ParsleyUI to append error messages to each field's grandparent.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top