Reputation: 997
I'm attempting to use ParsleyJS to validate my fields, and I've written a custom validator that will hopefully in the future allow me to check if a field is either blank or not equal to another field, but it simple never seems to be called. I previously attempted to combine the two validators and the notblank validator didn't get called, so I wrote this. Here is my custom validator and a link to a jsfiddle you can play with for the issue. What am I doing wrong? Thank you in advance for any help!
$(function () {
$('#form').parsley({
validators: {
notblankequalto: function (val, notblankequalto) {
return {
validate: function () {
alert('hi');
return false;
},
'priority': 2
}
}
},
messages: {
notblankequalto: "This value should be equal to the value above it"
}
});
});
Upvotes: 1
Views: 542
Reputation: 997
The issue ended up being less than obvious and I'm not entirely sure WHY it was presenting itself. When I changed the "optional" class to "required" it began working again. Then I could use the parsley-equalto as well as parsley-notblank.
Upvotes: 2
Reputation: 3405
The form id should be form
, not #form
.
See fiddle : http://jsfiddle.net/JmPfQ/9/
Upvotes: 1