views:

37

answers:

1

Hi,

I have a datefield in a form like this:

{
                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 user to use dd-mm-yyyy format, but with the above code the user can type 01102010 for 1st of october 2010.

I thought that format:'d-m-y' would force this, but it dont.

Validation should be clientside.

So either the field should reformat the date to 01-10-2010 onblur or it should just not allow other formats than dd-mm-yyyy. Last version is prefered :)

Thanks in advance!

+1  A: 

Hi,

Just did a bit more researching in the api documentaion and found

altFormats:'d-m-Y',

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

sunebrodersen