PDA

View Full Version : Validating TextField not working anymore with ExtJS 3.2.1



spruneau
22 Jun 2010, 7:48 AM
Hello,

I have a bunch of TextField that I validate independently. My problem is that nothing happens when I type invalid values in my textfield (it was working very well before).

I first specifiy several vtypes :


Ext.form.VTypes["string"] = /^(!?([0-9 a-z---%_]*|null))([,&]!?([0-9 a-z---%_]*|null))*$/i;
Ext.form.VTypes["int"] = /^(!?(\d{0,10}%?|null)|\d{1,10}[<>]%|%[<>]\d{1,10}|\d{1,10}[<>]%[<>]\d{1,10})([,&](!?(\d{0,10}|null)|\d{1,10}[<>]%|%[<>]\d{1,10}|\d{1,10}[<>]%[<>]\d{1,10}))*$/;
...

The regexp works for sure. Then I generate my TextFields like this :


new Ext.form.TextField({
id: 'myid',
name: "myname",
allowBlank:true,
width: '75',
height: 20,
vtype: 'int',
renderTo: 'renderId'
})Since my TextFields are standalone (not included in a Panel), I used this trick to configure the display of tips when my field is not valid :


Ext.form.Field.prototype.msgTarget = 'side';
Ext.form.TextField.prototype.defaultAutoCreate = {tag: 'input', type: 'text', size: '20', autocomplete: 'on'};
Ext.form.Field.prototype.getErrorCt = function ()
{
var el = this.el.findParent("div",5,true)
el.setStyle("position","relative");
return el;
}
Ext.form.Field.prototype.alignErrorIcon = function()
{
this.errorIcon.setStyle("position","absolute");
this.errorIcon.setStyle("top","0");
this.errorIcon.setStyle("right","-20px");
this.errorIcon.setStyle("left","auto");
}I'm unable to find where the problem comes from. Even when I set allowBlank to false in order to force validation, it looks like the validation is never called. I can type anything, nothing happens.

I'm really stuck here, have you any leads (or solution) for me ?

Thank you very much for your help,

Best Regards,

--
Stephen Pruneau