John
John

Reputation: 129

How to set date restriction for jqxGrid date column?

How can I set maximum or minimum date in jqxGrid date column field

$('#jqxGrid-grid').jqxGrid({
columns: 
[
{ 
  text: 'Created Date', datafield: 'created_date', filtertype:'date', width: 150} 
 //How to set date restriction for this field.
]
});

Upvotes: 0

Views: 1199

Answers (1)

scripto
scripto

Reputation: 2297

You can validate your users input by implementing the jQWidgets Grid's validation function.

   text: 'Ship Date', datafield: 'date', columntype: 'datetimeinput', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'd',
              validation: function (cell, value) {
                      if (value == "")
                         return true;
                      var year = value.getFullYear();
                      if (year >= 2015) {
                          return { result: false, message: "Ship Date should be before 1/1/2015" };
                      }
                      return true;
                  }

Upvotes: 1

Related Questions