There is a simple sample with column validation:
function requiredFieldValidator(value) {
if (value == null || value == undefined || !value.length) {
return {valid: false, msg: "This is a required field"};
} else {
return {valid: true, msg: null};
}
}
and to validate column it is just needed to put this option: validator: requiredFieldValidator
But how can I use regex function if I need to pass extra parameter – regex string.
By default, you cannot pass more parameters into the
validatormethod, however you can easily edit the source to allow it.in
slick.editors.jslook for:change:
var validationResults = args.column.validator($input.val());to:
var validationResults = args.column.validator($input.val(), $input);this will change your validator method signature to something like:
With that, you can get whatever attributes you want out of input with
input.attr('validation-expression')orinput.data...or whatever.