Reputation: 31
I use Ext.form.DateField with specified format is 'd/m/Y', like this:
{
xtype : 'datefield',
fieldLabel : 'Value Date <span style="color:red">*</span>',
name : 'valueDate',
allowBlank : false,
blankText : 'Please enter a Start Date',
msgTarget : 'under',
format : 'd/m/Y',
emptyText : 'dd/mm/yyyy'}
I want this component to complete the input value automatically with given format after it press tab key. I mean if I input the text '04022015' , it must display that text as '04/02/2015'. But when I input the text '04022015' and press tab key it display as 02/04/2015, I don't know how to make it work as I expect above. Could you please help me on this? Thank you so much!
Upvotes: 1
Views: 265
Reputation: 755
Take a look at the altFormats config. By default the parsing patterns are:
"m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|n-j|n/j"
Where | is the separator between different formats. As you can see the order is m-d-y by default. Just change this string to:
"dmy|dmY|d/m/y|d/m/Y|d-m-y|d-m-Y" // or similar...
Any formats you wish to be able to parse need to be there.
Upvotes: 1