PDA

View Full Version : How to validate the combo box using before query to filter.



raj542
12 Apr 2012, 4:36 AM
Hi,

I am filtering a combo box using beforequery, and i want to validate the user to enter the ? maximum three times.how can i achieve it? i am using this, but i am getting error like:
Uncaught ReferenceError: markinvalid is not defined extjs

filterMetadata: function(e,combo){
if (e.query && e.query.indexOf('?') != -1) {
var temp = '';
for(var i=0;i<e.query.length;i++){
if(e.query[i] === "?"){
var metadataStep1 = Ext.getCmp('step2');
metadataStep1.check = metadataStep1.check + 1;
if(metadataStep1.check == 4){

//invalid(combo,"max three?s");
markInvalid("maximum three?s");
}
}
temp = temp + '['+e.query[i]+ ']';
}
e.cancel = true;
var query = new RegExp(String.format('^{0}',temp.replace(/\?/g, 'a-zA-Z0-9\-.,:+*()=\'&_\\s')));
if (combo.store.getCount() > 0 || combo.listEmptyText) {
combo.expand();
combo.restrictHeight();
}
combo.store.clearFilter(true);
combo.store.filter(combo.displayField, query);
}
}

Thanks in advance,
Raj

khmurach
12 Apr 2012, 4:45 AM
Try


combo.markInvalid('msg');

raj542
12 Apr 2012, 4:54 AM
Hi khmurach,
i have tried the same, by that when i enter the ? for third time its just showing red mark like a blink and disappearing withou message.
one more thing if i enter other than ? also its entering into this if loop!!!!
if(e.query[i] === "?"){
var metadataStep1 = Ext.getCmp('step2');
metadataStep1.check = metadataStep1.check + 1;
if(metadataStep1.check == 4){

//invalid(combo,"max three?s");
combo.markInvalid("maximum three?s");
}