Check Date in ExtJS

I have a date field in this form:

{
                xtype:'datefield',
                name:'order[date]',
                id:'dato',
                format:'d-m-Y',
                allowBlank: false,
                cls:'input_single',
                emptyText:'dd-mm-yyyy',
                minValue:new Date().add('d',-1),
                onFocus: function(){
                    if (this.el.getValue() == 'dd-mm-yyyy') {
                        Ext.getCmp('dato').setValue('');    
                    }

                },
                msgTarget:'side',
                minText:'Must be future date',
                validationEvent:false


            }

Now my problem is that I want to force the user to use the dd-mm-yyyy format, but with the code above, the user can enter 01102010 on October 1, 2010.

I thought the format: "dmy" will force this, but it is not.

Validation must be on the client side.

Thus, either the field should reformat the date before 01-10-2010 onblur, or it should simply not allow other formats than dd-mm-yyyy. The latest version is preferable :)

Thanks in advance!

+3
source share
2 answers

Just worked a bit in documentaion api and found

altFormats:'d-m-Y',

This solved the problem. Now it will accept only the above format.

+1

VType, , . , . : http: docs/#!/Api/Ext.form.field.VTypes

0

Source: https://habr.com/ru/post/1767592/


All Articles