ExtJS vtype as a function
Is there any way to test a vType on a value, without it being in a form?
Eg I have a custom vtype implemented to do ajax validation, however I would also like to run it against the email vtype, so I was hoping to run something inside my custom开发者_StackOverflow社区 vtype along the lines of
validate('abc@de.ce','email');
You could use functions instead of properties, then you could just call 'em:
Ext.apply(Ext.form.VTypes, {
// Validates an ajax thingy
ajax: function(v) {
// validate against email VType
return Ext.form.VTypes.email(v);
},
// Override the default Ext function, to allow oddly-placed hyphens
email: function(v) {
var regex = /^[-\w][-+\.\w]*@[-\w\.]+\.[A-Za-z]{2,4}$/;
return regex.test(v);
}
}
Ext.form.VTypes.ajax('abc@de.ce');
精彩评论