2 Replies Latest reply on Apr 29, 2011 7:51 AM by Devtron

    Disable Past dates in mx:DateField

    Dhaval (Dotsquares)

      I'm  using DateField for the startDate input. How to not allow users to select a past date, the dates after today, in the DateField?

        • 1. Re: Disable Past dates in mx:DateField
          jfb00 Level 3

          Hi,

          Try this:

          var today:Date = new Date();
          var endDate:Date = new Date(today.getFullYear(),today.getMonth(),today.getDate()-1);
          myDate_df.disabledRanges = [{rangeEnd:endDate}];

           

          Rgds

           

          Johnny

          • 2. Re: Disable Past dates in mx:DateField
            Devtron Level 3

                                            <mx:DateField id="dfStartDate"
                                                name="Start Date"
                                                styleName="dateField"
                                                disabledRanges="{[getTomorrowDate(),{rangeStart: getTomorrowDate()}]}" />

             

             

             

                        private function getTomorrowDate():Date {
                            var tomorrow:Date = new Date()
                            tomorrow.date += 1; //increment date to tomorrow, so we can disable it in the picker controls
                            return tomorrow;
                        }

             

             

            this disables everything after today.

             

            reverse it, if you want the opposite. use rangeEnd instead.

            1 person found this helpful