0
示例here完美地解釋瞭如何爲Handsontable定義自定義驗證器。如何爲Handsontable中的每列定義自定義驗證器
例子:
(function(Handsontable){
function customValidator(query, callback) {
// ...your custom logic of the validator
callback(/* Pass `true` or `false` based on your logic */);
}
// Register an alias
Handsontable.validators.registerValidator('my.custom', customValidator);
})(Handsontable);
從現在起,您可以使用customValidator
像這樣:
var hot = new Handsontable(document.getElementById('container'), {
data: someData,
columns: [
{
validator: 'my.custom'
}
]
});
由於這個驗證驗證每個列的數據。 但我只想驗證一列只有。