Question

I'm developing an Android application using Appcelerator Titanium.

In that application I need to show a date picker when a particular text field is selected. The maximum value of date should be limited to current date and minimum value should be limited to 1990 Jan 1.

What I have tried so far

1

dateEntry.addEventListener('focus', function(e) {
    var date = dateEntry.value;
    var picker = Ti.UI.createPicker({
        type:Ti.UI.PICKER_TYPE_DATE,
        minDate:new Date(1990,01,01),
        maxDate:new Date(),
        value:new Date(),
    });
    picker.showDatePickerDialog({
        value: new Date(),
        callback: function(e) {
            if (e.cancel)
            {
                dateEntry.value = date;
            }
            else
            {
                date = e.value;
                dateEntry.value = date;
            }
            dateEntry.blur();
        }
    });
});

But it is not working.

2

I set maxDate and minDate for the pickerDialog also but it also not working.

3

I hard-coded the current date as maxDate, it is also not working.

How can I achieve this ? Please help me, Thanks in advance.

Was it helpful?

Solution

Midhun, This is a bug with Titanium. You can see the comment by Ygor Lemos at Jira.

It won't work if you use the Date Picker together with the showDatePickerDialog() method. It just ignores the min/max dates parameters.

Another option you have is validate the date selected with the current date.

OTHER TIPS

try this :

var picker = Ti.UI.createPicker({ type : Ti.UI.PICKER_TYPE_DATE, minDate : new Date(1990,00,01), //1990 Jan 1 maxDate : new Date(), // Current Date value : new Date(), });

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top