Parsley is based on data attributes, that are binded by jQuery with .data()
Unfortunately, when you add a data- attr, it is not binded to jQuery .data()
. You'll have to add the validators this way on the fly:
<script>
// wait for the DOM to be loaded
$(document).ready(function() {
// destroy
$('#myForm').parsley('destroy');
// change attribute
$('#myTestField').data('minlength', 2);
// assign parsley to do the job
$('#myForm').parsley();
});
</script>
I'll add an API to add / edit / remove validators on the fly, without having to call destroy :)