Extjs Custom Vtype
im trying validate a textfield with a custom vtype to filter white spaces, ex: ' '. I defined my custom vtype in the app.js (im using mvc pattern). Ext.Loader.setConfig({
Solution 1:
I put my custom vtypes in my app's controller on before render form.
Ext.define('MyApp.controller.Main', {
extend: 'Ext.app.Controller',
...
init: function () {
var me = this;
me.control({
...
'form': {
beforerender: this.applyVtypes
},
...
})
},
...
applyVtypes: function() {
Ext.apply(Ext.form.field.VTypes, {
descartarBlanco: function(value) {
return /^\s+$/.test(value);
}
}
}
...
}
Solution 2:
I reached this question trying to find a solution as I faced the same issue. It worked fine when I added it to 'init:' in Ext.application.
Ext.application({
...,
launch: function() {
...
},
init: function() {
Ext.apply(Ext.form.field.VTypes, {
descartarBlanco: function(value) {
return /^\s+$/.test(value);
}
}
console.log(Ext.form.field.VTypes); // for verification
}
})
Solution 3:
You can configure your own email validation.
xtype:'textfield',
fieldLabel: 'Email',
name: 'email',
maskRe: /[a-z0-9_.-@+]/i,//You can change it acccording to your requirement.
Solution 4:
Might be the same issue but with Ext.data.Types it only worked when the type name was uppercase. When lowercase would get a similar message as to what you are seeing.
Solution 5:
You use Ext.Loader
so Ext.form.field.VTypes
can be overwritten somewhere later. Try to add your vtype definition just before you actually use it.
Post a Comment for "Extjs Custom Vtype"