View Full Version : How to set default input type for the Date Field

18 Jan 2011, 1:27 AM
While i am using the DateField eg:01062001 it will display as 06-jun-2001 ,but i want it to be displayed as 01-jan-2001..It is taking 3rd and 4th as date 1st and 2nd as month ,i need in reverse.

18 Jan 2011, 2:11 AM
Read API

18 Jan 2011, 2:33 AM
thnx danguba ,
In order to do that ,do i need to write the whole dateFiled ? by replacing my own format..

18 Jan 2011, 2:35 AM
Also look at

"format" specifies the default format for displaying and input, while altFormats specifies the alternate syntaxes. What you want is to change altFormats so it accepts fields in reversed order. In our app we have a global setting for US / ISO calendar format, and based on this format and altFormats are initialized to appropriate values on Ext.form.DateField.prototype

18 Jan 2011, 4:56 AM
Here is a simplified version of the script that does our calendar format:
- startDay: start day for calender picker (starts on sunday for us, starts on monday for iso)
- format: date format for display (differs)
- emptyText: empty hint text for date fields
- altFormats: input formats (the different formats that can be typed in a date field)

$bUseIsoCalendar = TRUE / FALSE;
$strCalendarStartDay = ($bUseIsoCalendar ? "1" : "0");
// n = month with optional leading zeroes; j = day of month with optional leading zeroes
$strDateFormat = ($bUseIsoCalendar ? "d/m/Y" : "m/d/Y");
$strDateFormatAlt = ($bUseIsoCalendar ? "j/n/Y|j-n-y|j-n-Y|j/n|j-n|dm|dmy|dmY|d|Y-n-j" : "n/j/Y|n-j-y|n-j-Y|n/j|n-j|md|mdy|mdY|d|Y-n-j");
$strDateEmpty = ($bUseIsoCalendar ? "dd/mm/yyyy" : "mm/dd/yyyy");

Ext.util.Format.date = function(v, format){
if(!v) return "";
if(!(v instanceof Date)) v = new Date(Date.parse(v));
return v.dateFormat(format || <?php echo json_encode($strDateFormat); ?>);

Ext.apply(Ext.DatePicker.prototype, {
format : <?php echo json_encode($strDateFormat); ?>,
startDay : <?php echo strval($strCalendarStartDay); ?>

Ext.apply(Ext.form.DateField.prototype, {
emptyText : <?php echo json_encode($strDateEmpty);?>,
format : <?php echo json_encode($strDateFormat); ?>,
altFormats : <?php echo json_encode($strDateFormatAlt); ?>,
startDay : <?php echo strval($strCalendarStartDay); ?>