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.
ParsleyJS Custom validator skips validation with no error
-
30-09-2022 - |
Question
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"
}
});
});
La solution
Autres conseils
The form id should be form
, not #form
.
See fiddle : http://jsfiddle.net/JmPfQ/9/
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow