Time validation

var err_str=“”;
function validate_grid(value,id,ind)
{
if(ind==1 || ind==2)
{
var patt=/^([0][0-9]|[0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/;
if(!patt.test(value))
{
mygrid.setCellTextStyle(id,ind,“background-color:yellow;”);
if(err_str!=“”)
err_str+=“\n”+(ind+1)+“.Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]”;
else
err_str=(ind+1)+“.Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]”;
return false;
}
else
{
mygrid.setCellTextStyle(id,ind,“background-color:white;”);
return true;
}
}
}
here ind==1 is from_time & ind==2 is to_time,now i need to validate that to_time should be greater than from_time & it should accept only numbers and (:slight_smile:

please help me how to do the validation for time

Im validating time between two cell values fromtime(ind==1) and totime(index==2) where time should accept only numbers and (:slight_smile: (totime should be greater than from time)else it should alert an error msg.

[code]myDataProcessor.setVerificator(1,validate_grid);
myDataProcessor.setVerificator(2,validate_grid);
//validation code:

var err_str="";
function validate_grid(value,id,ind)
{
if(ind==1 || ind==2)
{
var patt=/^([0][0-9]|[0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/;//accepts only numbers & (:slight_smile:
if(!patt.test(value))
{
mygrid.setCellTextStyle(id,ind,“background-color:yellow;”);
if(err_str!="")
err_str+="\n"+(ind+1)+".Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]";
else
err_str=(ind+1)+".Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]";
return false;
}
else
{
mygrid.setCellTextStyle(id,ind,“background-color:white;”);
return true;
}
}
}[/code]

NOTE:here ind==1 is fromtime and ind==2 is totime .i need to validate time where fromtime should be less than totime and totime should be greater than fromtime.

If you need to compare values from multiple cell, you can use a single verification function

[code]myDataProcessor.setVerificator(1, validate_grid);
//validation code:
var err_str = “”;

function check_valid(value, ind){
var patt = /^([0][0-9]|[0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; //accepts only numbers & (:slight_smile:
if (!patt.test(value)) {
mygrid.setCellTextStyle(id, ind, “background-color:yellow;”);
if (err_str != “”) err_str += “\n” + (ind + 1) + “.Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]”;
else err_str = (ind + 1) + “.Enter numbers and (:slight_smile: only…[ex.05:00 24hr format]”;
return false;
} else {
mygrid.setCellTextStyle(id, ind, “background-color:white;”);
return true;
}
}

function validate_grid(value, id, ind) {
var val1 = grid.cells(id, 1);
var val2 = grid.cells(id, 2);
var mode = check_valid(val1,1);
mode = check_valid(val1,2) && mode;

if (!mode){
	//data is invalid
} else {
	//compare dates here
	if (val1 > val2) do_some();
	//this probablly need to be changed to more complex comparation logic
}

}[/code]