Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to validate date in Material Table?

This is the code of my table.

const [columns, setColumns] = useState([
    { title: 'S.No', field: 'S_No_Format', editable: 'never'},
    { title: 'Date', field: 'Date_Format', type : 'date', sorting: false  },
    { title: 'Description', field: 'Description', sorting: false ,validate: rowData => rowData.Description === '' || rowData.Description === undefined  ? { isValid: false, helperText: 'Invalid Description' } : true  },
    { title: 'Hours', field: 'Hours',  type: 'numeric', sorting: false ,validate: rowData => rowData.Hours === '' || rowData.Hours === undefined || rowData.Hours < 0 ? { isValid: false, helperText: 'Invalid Hours' } : true},
]);

const [DataArray , setDataArray] = useState([]);

return (
    <React.Fragment>
    <Navbar />
    <div>
        <MaterialTable
            title="Timesheet"
            columns={columns}
            data={DataArray}
            icons={tableIcons}
            editable={{

            onRowAddCancelled: rowData => console.log('Row adding cancelled'),
            onRowUpdateCancelled: rowData => console.log('Row editing cancelled'),
            onRowAdd: newData =>
                new Promise((resolve, reject) => {
                    setTimeout(() => {
                        newData.Date_Format = Date_To_Regular(newData.Date_Format);
                        console.log(newData)
                        
                        resolve();
                    }, 1000);
                })  
            
            }}
            options={{
                actionsColumnIndex: -1,
                search:false,
                exportButton: true,
                
            }}
        />
    </div>
    </React.Fragment>
);

I want to validate the date while adding a new row. The date selected should either be today , yesterday or day before. How do I validate the date?

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!