Tabulator: how to validate table data submit by other function before?

Created on 23 Jan 2018  Â·  3Comments  Â·  Source: olifolkerd/tabulator

I want to save all table data,but how to validate(required), thanks

Question - Ask On Stack Overflow

Most helpful comment

This is very well documented in the documentation

Here is an example from this documentation, which you should read.

//validator to prevent values divisible by five
var noDivideFive = functioncell, value, parameters){
    //cell - the cell component for the edited cell
    //value - the new input value of the cell
    //parameters - the parameters passed in with the validator

    return value % 5; //dont allow values divisible by 5;
}

//in your column definition for the column
{title:"Age", field:"age", editor:"input", validator:noDivideFive}

All 3 comments

This is very well documented in the documentation

Here is an example from this documentation, which you should read.

//validator to prevent values divisible by five
var noDivideFive = functioncell, value, parameters){
    //cell - the cell component for the edited cell
    //value - the new input value of the cell
    //parameters - the parameters passed in with the validator

    return value % 5; //dont allow values divisible by 5;
}

//in your column definition for the column
{title:"Age", field:"age", editor:"input", validator:noDivideFive}

thanks for your help.
Can we do like this?
var isvalid = $("#the_table").tabulator("isvalid");
if(isvalid){
// todo something
}
@Rodbjartson

Hey @jiaqianliCn

The validation in tabulator does not work like this, it will not let you enter invalid data into the table in the first place so all data contained within the table is always valid (as long as it was valid in the first place when it was set with the setData function).

if validation fails the validationFailed callback is called and you can trigger an action from that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KES777 picture KES777  Â·  3Comments

KES777 picture KES777  Â·  3Comments

aditya-thimphu picture aditya-thimphu  Â·  3Comments

yaxino picture yaxino  Â·  3Comments

cemmons picture cemmons  Â·  3Comments