3.2.0

Regular expressions when Editing.

Hello,

I want my editable cells to accept only digits, or characters. So I want to use regular expressions to control cells.

I check the entered text in obj.onCellTextChanged, and if the entered data is matching with the regular expression ( for example all of them are digits ) its ok, but if not I want to set the cells data to its old value.

But it is not possible to change the text to another value in obj.onCellTextChanged.. it seems actually obj.onCellTextChanged is called not after cell text changed..

is there any idea?

proposal : a modification of setting regular expressions for each column would be nice in an upgraded version

function numCheck(num) { 
    var numRE = /^\d+$/ ; 
    if (numRE.exec(num)) {
        return true; 
    } else { 
        return false; 
    } 
    };

            obj.onCellEditStarted = function(a,column,row)
    {
        
        oldtext = this.getCellText(column,row);
    }
    obj.onCellTextChanged = function(a,column,row)
    {
        if ( column==2 )
        {
            var newtext = this.getCellText(column,row);
            if ( !numCheck( newtext ) )
            {
                alert("olmaz "+a);
                a = "5";
                this.setCellText(oldtext, column, row);
                return false;
            }
                
        }
        if (obj.getRowCount()>0)
        {
            setDirty(row);	
        }
    }
Ozgur
February 23,

This topic is archived.

See also:


Back to support forum