Is there a way I can manually add a red border to a cell if the data that was entered did not pass my own validation? Currently, I’m using beforeChange. Inside the callback, I process the new data, my own validation, and all. What I want to achieve is that, if for example, the validation failed, I would mark that cell with a red border, and maybe still stay on that cell – will not proceed to other cell if Enter was pressed, etc.
If it comes to the border for invalid cells you have two approaches.
The first one is an override existence class .htInvalid by .handsontable table td.htInvalid { background-color: white !important; border: 1px solid red !important; } - https://jsfiddle.net/aoyqtv3d/
However, I’m not using your own validators, I want to use another library. For example, I want to use validatorJS, after I validate using validatorJS and it failed, how can I set that specific cell border color red? Without using your own validator.
And this will not be only limited to validatorJS, what if I want to use additional libraries. So, this is not regarding the validators that I will use, but the goal is how to set that specific cell manually without going through the HandsOnTable’s validator.
Thank you for your reply and solution. However, upon reading the description for afterValidate it will only fire if there is a validator function defined
I’m using my own validator on the fly, inside the beforeChange call, that’s why I’m asking if there is a way I can - manually - change the cell’s border being edited (if validation failed). Like setting the cell meta or any way that functions similarly.
If you have a validation error, you could use setCellMeta inside beforeChange to set a className for instance to .highlight--error.
In CSS area define this class as .highlight--error { background-color: white !important; border: 1px solid red !important; }.