Edit Selectable Dates in DateField
im trying to create an event form where the datefield will only allow a date from a specific amount of dates to be selected from.
For example, something like this: if the date (today) is greater than the monday of the 4th week of the month, (so for this month, February, it would have to be > 20th) then this month (would be nice if it also eliminated the previous days that already passed in the month) and next month is has available dates to select. Else (if less than the 4th week of the month, <20 for february) only this month(february) is has available dates to be picked from.
Just wondering how can you do this with a <cfinput type="datefield> tag. I have come up with something but am not sure how to go from here.
//Cfset's
<cfset theDate = Now()>
<cfset NextMonth = DateAdd('m', 1, theDate) />
<cfset nextMonthNum = daysInMonth(#NextMonth#) />
<cfset weekNum = (#weekOfMonth(now())#) />
<cfset daysNum = daysInMonth(now()) />
<cfset dateToday = Now()>
//Datefield
<cfinput
type="datefield"
label="date"
mask="mm/d/yy"
name="activitydate"
value="#dateAdd('d', +1,now())#"
required="yes"
message="Please Select a Valid Date for Event" />
//This is where it checks for the amount of days and loops them through giving the range of available dates from the begining of the month.
<cfscript>
function weekOfMonth(thisDate) {
var thisDay=day(thisDate);
var thisWeek=0;
if (thisDay LTE 7)
thisWeek=1;
else if (thisDay GT 7 AND thisDay LTE 14)
thisWeek=2;
else if (thisDay GT 14 AND thisDay LTE 21)
thisWeek=3;
else
thisWeek=4;
return thisWeek;
}
</cfscript>
<cfif #DatePart('w', TheDate)# GTE 4 AND #weekNum# GTE 2>
True<br />
<cfloop index="x" from="1" to="#daysNum#">
<cfoutput>
#DateFormat(now(), "mm")#/#x#/#DateFormat(now(), "yy")# <br />
</cfoutput>
</cfloop>
<cfloop index="y" from="1" to="#nextMonthNum#">
<cfoutput>
#DateFormat(NextMonth, "mm")#/#y#/#DateFormat(NextMonth, "yy")#<br />
</cfoutput>
</cfloop>
<cfelse>
False<br />
<cfloop index="z" from="1" to="#daysNum#">
<cfoutput>#DateFormat(now(), "mm")#/#z#/#DateFormat(now(), "yy")# <br /></cfoutput>
</cfloop>
</cfif>
Any help greatly appreciated!
