[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Concatenating Date Values

Asked by christie_holtz in Miscellaneous Web Development

Tags: java

Hello!  I'm using the following java script to check the validity of dates that are entered.  I need to concatenate the validated fields: startday, startmonth, startyear, etc. in the start_dt.  The format should be a date startmonth/startday/startyear.  I tried just using cfset start_dt=#startmont# + #startday# + #startyear#, but that gives me an error.  I'll give 500 points and I definite A for answer.

                        <cfform name="Insertform" method="post" action="./report_vacation.cfm">
                          <script language="JavaScript"><!--
function padout(number) { return (number < 10) ? '0' + number : number; }

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function validate(what) {
    var startday = what.startday.options[what.startday.selectedIndex].value;
    var startmonth = what.startmonth.options[what.startmonth.selectedIndex].value;
    var startyear = what.startyear.options[what.startyear.selectedIndex].text;
    var endday = what.endday.options[what.endday.selectedIndex].value;
    var endmonth = what.endmonth.options[what.endmonth.selectedIndex].value;
    var endyear = what.endyear.options[what.endyear.selectedIndex].text;

    unvalidstartdate = startday + '/' + startmonth + '/' + startyear;
    unvalidenddate = endday + '/' + endmonth + '/' + endyear;

    var startdate = new Date(startyear-0,startmonth-1,startday-0);
    var enddate = new Date(endyear-0,endmonth-1,endday-0);

    var validstartdate = padout(startdate.getDate()) + '/' + padout(startdate.getMonth()+1) + '/' + y2k(startdate.getYear())
    var validenddate = padout(enddate.getDate()) + '/' + padout(enddate.getMonth()+1) + '/' + y2k(enddate.getYear())
   
    if (unvalidstartdate != validstartdate) {
        alert('Start Date: ' + what.startday.options[what.startday.selectedIndex].text +
                         ' ' + what.startmonth.options[what.startmonth.selectedIndex].text +
                         ' ' + what.startyear.options[what.startyear.selectedIndex].text + ' is invalid');
        return false;
    }

    if (unvalidenddate != validenddate) {
        alert('End Date: ' + what.endday.options[what.endday.selectedIndex].text +
                       ' ' + what.endmonth.options[what.endmonth.selectedIndex].text +
                       ' ' + what.endyear.options[what.endyear.selectedIndex].text + ' is invalid');
        return false;
    }

    starttime = Date.UTC(y2k(startdate.getYear()),startdate.getMonth(),startdate.getDate(),0,0,0);
    endtime = Date.UTC(y2k(enddate.getYear()),enddate.getMonth(),enddate.getDate(),0,0,0);
   
    if (starttime < endtime) {
        // valid
    }
    else {
        alert('Start Date is not less than End Date');
        return false
    }
   
    currentdate = new Date();
    currenttime = Date.UTC(y2k(currentdate.getYear()),currentdate.getMonth(),currentdate.getDate(),0,0,0);
   
    if (starttime > currenttime) {
        // valid
    }
    else {
        alert('Start Date cannot be less then todays date');
        return false;
    }
   
    what.startdate.value = validstartdate;
    what.enddate.value = validenddate;
      
    return true;
      
                                                      
}
//--></script>
[+][-]03/14/05 09:58 AM, ID: 13537154Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Miscellaneous Web Development
Tags: java
Sign Up Now!
Solution Provided By: YZlat
Participating Experts: 2
Solution Grade: A
 
[+][-]03/14/05 10:04 AM, ID: 13537196Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/14/05 10:43 AM, ID: 13537514Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/14/05 11:19 AM, ID: 13537867Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/14/05 12:32 PM, ID: 13538578Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93