Hi,
mygrid.attachEvent(“onEditCell”,function(stage,rowId,cInd){
if(cInd > 0 && stage == 1)
{
if(mygrid.editor && mygrid.editor.obj )
{
mygrid.editor.obj.onkeypress = function(e){
if(this.value > 100){
alert(“Value cannot be greater than 100”);
this.value = “”;
return false;
}
if(this.value.length>=5){
return false;
}
}
}
}
return true;
})
in the above code validation for “Value cannot be greater than 100” doesn’t work. It accepts values grater than 100 without poping up any alert to the user. user is only alerted when the cell clicked to edit.
To solve issue , change
mygrid.editor.obj.onkeypress = function(e){
to the
mygrid.editor.obj.onkeyup = function(e){
The browser works in next way
- key pressed
- onkeydown event
- onkeypress event
- value of input changed
- onkeyup event
so if you want to get new value of the input, you need to use onkeyup event ( on other hand - “return false” has not sense for onkeyp event, because value already changed )