如何让我的正则表达式代码在我的dojo cellWidget对象上工作



如何让正则表达式代码在dojo cellWidget对象上工作?我试图让这个正则表达式在两个地方工作,一个是IP地址,另一个只是一个简单的数字字段,用于0和3000之间的值,但无论我尝试什么,它似乎都不喜欢。有时我可以键入一个个个数字,但我不会收到验证消息,否则我总是收到这两个数字的验证消息。我正在为这个使用dijit/form/ValidationTextBox

这是我的代码:

{ id: 'numberId', field: 'numberColumn', name: 'Number', width: '150px',
    widgetsInCell: true,
    navigable: true,
    setCellValue: function(gridData, storeData, cellWidget){
        var rowIndex = cellWidget.cell.row.index()+1;
        var toggle = numberGridx.model.store.get(rowIndex).numberColumn;
        cellWidget.numberColumn.set('regExp', "(100)|(0*d{1,2})");
        cellWidget.numberColumn.set('style', "width:115px");
        cellWidget.numberColumn.set('invalidMessage', "Dude that won't work!");
    },
    decorator: function(){
        return "<input type='text' data-dojo-type='dijit/form/ValidationTextBox' data-dojo-attach-point='numberColumn' />";
    }
},

我的另一个cellWidget正则表达式代码在这里(尝试了所有这些):

//                cellWidget.outProActFeedsDestAddr.set('regExp', "^d{1,3}.d{1,3}.d{1,3}.d{1,3}$");
//                cellWidget.outProActFeedsDestAddr.set('regExp', "m/^([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5])$/");
cellWidget.outProActFeedsDestAddr.set('regExp', "([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5])");

毫无疑问,我的同事也做了这个(我也尝试过类似的东西,但我认为双’s解决了它:

"([01]?\d\d?|2[0-4]\d|25[0-5])…"

cellWidget.outProActFeedsDestAddr.set('regExp', "([01]?\d\d?|2[0-4]\d|25[0-5])[.]([01]?\d\d?|2[0-4]\d|25[0-5])[.]([01]?\d\d?|2[0-4]\d|25[0-5])[.]([01]?\d\d?|2[0-4]\d|25[0-5])");

最新更新