Skip to main content
Known Participant
June 10, 2010
Question

cfinput question - javascript, DOM, etc.

  • June 10, 2010
  • 1 reply
  • 758 views

Hi, I have a form which includes the following inputs:

<cfinput type="datefield"
                           id="startDate"
                        name="StartDate"
                        value="#StartDate#"
                        message="Start Date is required!"
                        required="yes"
                        validate="usdate"
                        validateat="onsubmit">

<cfinput type="datefield"
                        id="endDate"
                        name="EndDate"
                        value="#EndDate#"
                        message="End Date is required!"
                        required="yes"
                        validate="usdate"
                        validateat="onsubmit">

I've written a JavaScript function that listens to the startDate field and if modified, sets the endDate field to the same time:

<script type="text/javascript" language="javascript">
                function populateEndDate(){                  
                    date = document.getElementById("startDate").value;
                    document.getElementById("endDate").value = date;
                }

This topic has been closed for replies.

1 reply

Inspiring
June 10, 2010

The subject line suggests that there is a question but the OP does not include one.

earacheflAuthor
Known Participant
June 10, 2010

unfortunately, hit the wrong button and the post was submitted prematurely

was going to add:

My problem is in how to trigger the script when inputting the date using  the cfCalendar date popup, which is the most convenient way to input  the date. Does the DOM apply to cfInput fields, and if so, which DOM  node would need to have an eventListener attached, and which event  should be used? Any help would be appreciated.

Inspiring
June 10, 2010

Is there an html version of cfcalendar?  I believe that when it came out it was flash only in which case js would not work.

Getting back to basic js, you need an event to trigger your function.  I'd go with startdate onBlur myself.