Skip to main content
Participant
September 10, 2008
Question

cfinput date range?

  • September 10, 2008
  • 2 replies
  • 788 views
Is it possible to use the range attribute for cfinput for a range of dates in CF 7?
I'm not finding any examples on how to accomplish this.

Thanks.
    This topic has been closed for replies.

    2 replies

    Inspiring
    September 10, 2008
    Set a minimum and maximum date that can be selected? I do not think there is a built in CF property for that. But it is possible using action script. Try this tip from Nick Watson, but use the selectableRange property instead of disabledRanges
    http://weblogs.macromedia.com/nwatson/archives/2006/03/disable_calenda.cfm

    The sample uses the less elegant cfsavecontent method. If you are running 7.0.1 (?) you could use <cfformitem type="script"> instead.

    <!--- set the allowed ranges for the calendar --->
    <cfset startDate = "09/15/2008">
    <cfset endDate = "09/20/2008">

    <cfoutput>
    <cfsavecontent variable="loadFields">
    <!--- this is not allowed with mx 7
    //var #ToScript( parseDateTime(startDate), "startDate", false, false)#
    //var #ToScript( parseDateTime(endDate), "endDate", false, false)#
    --->
    var startDate:Date = mx.formatters.DateFormatter.parseDateString("#startDate#");
    var endDate:Date = mx.formatters.DateFormatter.parseDateString("#endDate#");
    testDate.selectableRange = {rangeStart:startDate, rangeEnd:endDate};
    </cfsavecontent>
    </cfoutput>

    <cfform name="testForm" format="flash" onLoad="#loadFields#" width="200">
    <cfinput type="datefield" name="testDate" >
    </cfform>
    Inspiring
    September 10, 2008
    > Is it possible to use the range attribute for cfinput for a range

    I was assuming you meant with a <cfinput type="datefield"...>. If not, disregard my response. It does not apply.
    Inspiring
    September 10, 2008
    I don't think so. You can always write your own js to do that. Or you can do it with cold fusion when the form is submitted. Or you can do both.