Inside afterChange hook check every value match with my regex

Tags: #<Tag:0x00007f8b1cfd53f0> #<Tag:0x00007f8b1cfd5210>

Inside afterChange hook check every value match with my regex if value is not match with regecx then particular cell false with comment like Invalid value

//here is code
hot.addHook(‘afterChange’, function(changes, source) {
var regex = /^[a-zA-Z]{4}\d{7}$/;
column.forEach(function(value, row) {

                    var cell = instance.getCellMeta(row, 0);

                   

                    if(value != null){

                        if (regex.test(value)) {

                            alert("Matched");

                        } else {

                            alert("Not matched");

                            cell.valid = false

                            cell.comment = 'Error: Container no invalid'

                        }

                    }
   });
   hot.render()

});

cell.valid = false with comment is not working

Hi @patelchirag5011997

Thank you for contacting us. We have an example showing how to display a comment on an invalid cell after the validation process. You would rather use afterValidate hook, as it is also fired after each change: https://jsfiddle.net/handsoncode/nsov076x/

You can then attach your custom validator to the desired column. In your case you will need to add validator option to the columns configuration, and set it to your regex.