[#384,slickgrid][s]add validator function to validate input
This commit is contained in:
@@ -101,12 +101,12 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// we need to be sure that user is entering a valid input , for exemple if
|
// we need to be sure that user is entering a valid input , for exemple if
|
||||||
// field is date type and field.format ='YY-MM-DD', we sould be sure that
|
// field is date type and field.format ='YY-MM-DD', we should be sure that
|
||||||
// user enter a correct value
|
// user enter a correct value
|
||||||
var validator = function(field){
|
var validator = function(field){
|
||||||
return function(value){
|
return function(value){
|
||||||
if(field.type == "date" && isNaN(Date.parse(value))){
|
if(field.type == "date" && isNaN(Date.parse(value))){
|
||||||
return {valid: false, msg: "This format is required" + field.type};
|
return {valid: false, msg: "A date is required , check field field-date-format"};
|
||||||
}else {
|
}else {
|
||||||
return {valid: true, msg :null }
|
return {valid: true, msg :null }
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
minWidth: 80,
|
minWidth: 80,
|
||||||
formatter: formatter,
|
formatter: formatter,
|
||||||
validator:validator
|
validator:validator(field)
|
||||||
};
|
};
|
||||||
|
|
||||||
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column === field.id;});
|
var widthInfo = _.find(self.state.get('columnsWidth'),function(c){return c.column === field.id;});
|
||||||
|
|||||||
Reference in New Issue
Block a user