PDA

View Full Version : Common Vtype Validation method ?



29 Oct 2010, 5:03 AM
Hi,
I am new to extjs. I like to know, Is it possible to do dynamic vtype validation like below code...

function ConstructVtype()
{
var customRegEX = this.customRegEX; ////^[a-z0-9]/i,
customMsg =this.customErrorMsg;

Ext.apply(Ext.form.VTypes, {
AlphaNum: function(v,field) {
return customRegEX.test(v);
},
AlphaNumText: customMsg,
AlphaNumMask: customRegEX
});

}


var txt = new Ext.form.TextField({
renderTo:Ext.getBody(),
validator :ConstructVtype,
fieldLabel: 'Telephone',
name: 'Telephone',
vtype:'AlphaNum',
id:'test1',
customRegEX:'/^[a-z0-9]/i',
customErrorMsg:'Must be an alphanumeric word',
width:240

});

var txt2 = new Ext.form.TextField({
renderTo:Ext.getBody(),
validator :ConstructVtype,
fieldLabel: 'Telephone',
name: 'Telephone',
vtype:'AlphaNum',
id:'test2',
customRegEX:'/^[a-zA-Z]/i',
customErrorMsg:'Must be an alphabets',
width:240

});


how can create individual vtype for individual textfieild without override the previous one. OR

Provide How can i achieve this functionality


Thanks in advance