Reputation: 911
I am trying to add a custom validator
window.ParsleyValidator
.addValidator('invalidWords', {
requirementType: 'regexp',
validateString: function(value, requirement) {
console.log(value,requirement);
return /^\b(?:Stadium|GT|BB|HB|Simul|VNOSE|LT|combination|LT1|SSGT|BW|HBS|simul|combo|2hbs|4d|lt2|theatre)\b$/i.test(value)
},
messages: {
en: 'Invalid words detected.'
}
});
with HTML as...
<div class="col-sm-6 col-lg-6">
<div class="form-group">
<input type="text" name="company" data-parsley-group="eventinfo" id="Company" class="form-control" placeholder="Company" maxlength="60" tabindex="3" title="Company" parsley-trigger="keyup" data-parsley-invalidwords="" value="#request.args.company#">
</div>
</div>
I keep getting the error Callback must be instanciated with a function
and I am not sure why. I am following the directions on the site. http://parsleyjs.org/doc/index.html#custom
It also doesn't seem to trigger on keyup either.
using version 2.0.7
Upvotes: 0
Views: 375
Reputation: 911
I noticed I was on an older version so I have updated to 2.2-rc4
and the issue seems to be resolved.
Upvotes: 2