Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vijay on Feb 27, 2009 05:18
open dhtmlx forum
RE: Validating the element which is opened while editing a cell

Hi,

Thanks for your post and its working as I expected.

One thing is missed in YOUR last post. Can you please provide me YOUR valuable support for the below question(final).

I would like to restrict the number of characters to be entered in the text area. For example, the user should NOT be allowed to enter more than' 10' characters in the text area and it should restrict entering characters without intimation. This scenario should be covered for both events. 1. Entering characters by typing 2. Entering characters by pasting. Please do the needful.

 

 

Answer posted by dhxSupport on Feb 27, 2009 07:25

>>I would like to restrict the number of characters to be entered in the text area. For example, the user should NOT be allowed to enter more than' 10' characters in the text area and it should restrict entering characters without intimation.

function doOnEditCell(stage,rowId,cellInd,newValue,oldValue){
  if (stage==1){
  mygrid.editor.obj.onkeypress = function(e){
  if(this.value.length>=5){
  return false;
  }
  }
  return true;
  }
  if (stage==2){
  if (newValue==""){
  window.setTimeout(function(){
  mygrid.selectCell(mygrid.getRowIndex(rowId),cellInd);
  mygrid.editCell();
  },1);
  }
  }
  return true;
 }


>>This scenario should be covered for both events. [...] 2. Entering characters by pasting. Please do the needful.

There is no such event which could allow you catch pasting values directly to the open editor from clipboard. Only what you can do is to check newValue after editor was closed and cut unnecessary symbols.