HerrB
17 Jun 2009, 1:46 PM
Hi,
using the build-in vtypes is a convenient to check on basic data quality. Currently, specifying a vtype automatically means "field is mandatory" (allowblank setting is ignored).
If the allowblank setting is mentioned, even if a vtype has been specified, then optional fields could also be checked easily without the need to specify a validator function.
I know, it is unlikely that this feature would be integrated, as changing the current behaviour e.g. would make empty email fields valid, if vtype has been specified and allowblank hasn't been explicitly specified as "false".
So, it seems a rather bad idea - or what do you think?
Workaround:
allowBlank: true,
validator: function (strValue) {
if (strValue == '') {
return true;
} else if (Ext.form.VTypes.email(strValue)) {
return true;
} else {
return 'This field should be an e-mail address in the format "user@domain.com"';
}
Regards,
HerrB
using the build-in vtypes is a convenient to check on basic data quality. Currently, specifying a vtype automatically means "field is mandatory" (allowblank setting is ignored).
If the allowblank setting is mentioned, even if a vtype has been specified, then optional fields could also be checked easily without the need to specify a validator function.
I know, it is unlikely that this feature would be integrated, as changing the current behaviour e.g. would make empty email fields valid, if vtype has been specified and allowblank hasn't been explicitly specified as "false".
So, it seems a rather bad idea - or what do you think?
Workaround:
allowBlank: true,
validator: function (strValue) {
if (strValue == '') {
return true;
} else if (Ext.form.VTypes.email(strValue)) {
return true;
} else {
return 'This field should be an e-mail address in the format "user@domain.com"';
}
Regards,
HerrB