[1.0.1a] DateField fails to invoke custom vtype validator
From what i gather from this thread, specifying a custom vtype (like in here) for a DateField should work because DateField calls
Code:
if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
return false;
}
but it doesn't seem to be invoking the associated custom validation method.
My custom vtype follows:
Code:
Ext.apply(Ext.form.VTypes, {
mydateMask : /[\d\/]/, // only allow numbers and '/' in date fields
mydateText : "Date must be in DDMMYY, DD/MM/YY<br>or DD/MM/YYYY format",
mydate : function(v) {
var pd = Date.parseDate(v, 'dmy') || Date.parseDate(v, 'd/m/y') || Date.parseDate(v, 'd/m/Y');
return (pd != null && (v.length == 6 || v.length == 8 || v.length == 10));
}
});
When specifying vtype: 'mydate' in the DateField config, the mask mydateMask and invalidText mydateText are correctly applied, but the mydate validator is never called, and the default DateField format: 'm/d/y' and validator are used instead.
Also, when the above custom vtype is used, entering exactly 6 characters (digits only) causes the invalid field QuickTip to display the default DateField invalidText i.e. "{0} is not a valid date - it must be in the format {1}". Entering any other combination of digits and slashes (i.e. '/') will display the custom invalidText mydateText.
A complete test case follows:
HTML Code:
<html>
<head>
<title>DateField vtype test case</title>
<link rel='stylesheet' href='ext-all.css'>
<script src='yui-utilities.js'></script>
<script src='ext-yui-adapter.js'></script>
<script src='ext-all-debug.js'></script>
<script>
Ext.apply(Ext.form.VTypes, {
mydateMask : /[\d\/]/, // only allow numbers and '/' in date fields
mydateText : "Date must be in DDMMYY, DD/MM/YY<br>or DD/MM/YYYY format",
mydate : function(v) {
var pd = Date.parseDate(v, 'dmy') || Date.parseDate(v, 'd/m/y') || Date.parseDate(v, 'd/m/Y');
return (pd != null && (v.length == 6 || v.length == 8 || v.length == 10));
}
});
Ext.onReady(function() {
Ext.QuickTips.init();
var df = new Ext.form.DateField({
menu: new Ext.menu.DateMenu(), // all DateFields will share the same DateMenu instance
allowBlank: true,
vtype: 'mydate'
});
df.applyTo('myText');
});
</script>
</head>
<body>
<input type='text' id='myText' value=''/>
</body>
</html>