I need to make a form containing several fields, including the one that is giving me trouble: the date field.
in itself, what it does is very good, but it doesn't comply with the requirement not to auto-correct and simply get an "invalid date" error.
the case in question is February 30, which automatically changes to March 2.
you can easily reproduce this example on the official api: https://docs.sencha.com/extjs/6.2.0/classic/Ext.form.field.Date.html
enter 02302022 and the blur will change to 03/02/2022
I tried to change the validator to refuse my input this way, but it doesn't work because the Ext.Date.parse function also corrects the date!
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 300,
bodyPadding: 10,
title: 'Dates',
items: [{
xtype: 'datefield',
anchor: '100%',
fieldLabel: 'From',
name: 'from_date',
validator: function (val)
{
// manual
var man = Ext.Date.parse( val , 'mdY' ) != null ;
//formated
var formated = Ext.Date.parse( val , 'm/d/Y' ) != null ;
return manual || formated;
}
}]
});