How do I get my regular expression code working on my dojo cellWidget object?

廉价感情. 提交于 2019-12-12 06:08:59

问题


How do I get my regular expression code working on my dojo cellWidget object? I'm trying to get this regex working in two places, one with an IP address and another just a simple number field for values between 0 and 3000 but no matter what I try it seems to not like anything. Sometimes I can type a single digit number and I don't get my validation message, otherwise I always get the validation message on both of these. I am using a dijit/form/ValidationTextBox for this

Here is my code:

{ 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' />";
    }
},

My other cellWidget regex code is here (Tried all these):

//                cellWidget.outProActFeedsDestAddr.set('regExp', "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\$");
//                cellWidget.outProActFeedsDestAddr.set('regExp', "m/^([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])$/");
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])");

回答1:


Well, this one worked from my coworker no doubt (I had tried something similar, but I think the double '\'s is what solved it:

"([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])");


来源:https://stackoverflow.com/questions/29216116/how-do-i-get-my-regular-expression-code-working-on-my-dojo-cellwidget-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!