Parsley.js
Parsley.js copied to clipboard
Pass field element reference into validation callback
I have custom validators which not just check some hardcoded data conditions, but depends on validated input and/or it's neighbours state.
It requires at least reference to the input itself.
At first glance, it can be solved just adding input reference here (passing it through then into validateThroughValidator()
).
I've resolved it using this code:
validateThroughValidator: function (value, constraints, priority) {
var that = this;
$.each(constraints, function() { this.$element = that.$element });
return window.ParsleyValidator.validate.apply(window.ParsleyValidator, [value, constraints, priority]);
},
Related to #839
This would be very useful :+1: