I have the simplest possible form with the simplest custom validator and it is not working, see http://jsfiddle.net/M55M4/ What is wrong?
<form id="myform">
<input type="text" data-parsley-myvalidator="foo" data-parsley-required />
<input type="submit" />
</form>
$('#myform').parsley({
validators: {
myvalidator: function () {
return {
validate: function (value, requirements) {
alert('myvalidator');
return false;
},
priority: 32
}
}
},
messages: {
myvalidator: 'my validator failed'
}
});
If Parsley js version is not critical I recommend you to update it to the latest one - v.2.0.2. According to the new API, custom validator should be defined the following way (http://jsfiddle.net/M55M4/6/):
Accepted answer is deprecated now.
Example of custom validator: date format validation dd/mm/yyyy with momentJS:
This example for Parsley v 2.6.0 on plunker: http://plnkr.co/edit/hYDd19uPbJzKRVf9IMsH?p=preview