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

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)}
Code language: JavaScript (javascript)
Notify of
Inline Feedbacks
View all comments