RSS
magnify
Home General Add a month to selectable date range – Date Chooser – Actionscript 2
formats

Add a month to selectable date range – Date Chooser – Actionscript 2

Published on March 22, 2010 by in General

I have been working on a project where I need to select a date range starting today and ending a month from now, so the user cannot select anything in the past or over a month from now.

This is how I did it:

There is an instance of DateChooser on the stage with Instance Name “calDate”.

var todayDate:Date = new Date();
dateBeginDay = todayDate.getDate();
dateBeginMonth = todayDate.getMonth();
dateBeginYear = todayDate.getFullYear();

if ((todayDate.getMonth()+1)==12) {
        dateEndDay = todayDate.getDate();
        dateEndMonth = 1;
        dateEndYear = todayDate.getFullYear()+1;
} else {
        dateEndDay = todayDate.getDate();
        dateEndMonth = todayDate.getMonth()+1;
        dateEndYear = todayDate.getFullYear();
}
calDate.selectableRange = {rangeStart: new Date(dateBeginYear, dateBeginMonth, dateBeginDay), rangeEnd: new Date(dateEndYear, dateEndMonth, dateEndDay)}

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© Copyright © 2012 · Web Development London UK · All rights reserved · Site hosted on the hsmoore.com network
By using the site and/or making use of any of our services you agree to our Terms and Conditions