Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with varible assignment

Posted on 2016-08-23
2
Medium Priority
?
93 Views
Last Modified: 2016-08-24
Hello, with my code below I keep getting an error:
Uncaught Error: Syntax error, unrecognized expression: 8/23/2016 01:00:00

on this line when I try to populate: frdi
 if (frdiD != ''){
                   frdi = $(this.concatenateDateTime(frdiD, frdiT));
                }

I'm learning javascript and don't understand what this error means. What am I doing wrong?


 validateDates: function () {
                $('.firstSecondValMsg').html('');
                $('.secondClientValMsg').html('');

                var frdiD = $("#FirstReviewDeadlineInterim").val();
                var frdiT = $("#FirstReviewDeadlineInterimTime").val();
                var frdi = '';
                if (frdiD != ''){
                   frdi = $(this.concatenateDateTime(frdiD, frdiT));
                }

                var srdiD = $("#SecondReviewDeadlineInterim").val();
                var srdiT = $("#SecondReviewDeadlineInterimTime").val();
                var srdi = '';
                if (srdiD != '') {
                    srdi = $(this.concatenateDateTime(srdiD, srdiT));
                }
               
                var cdiD = $("#ClientDeadlineInterim").val();
                var cdiT = $("#ClientDeadlineInterimTime").val();
                var cdi = '';
                if (cdiD != '') {
                    cdi = $(this.concatenateDateTime(cdiD, cdiT));
                }

                if ($(this.compareTime(frdi, srdi)) && srdi != '') {
                    $('.firstSecondValMsg').html("First Review Deadline is greater than Second Review Deadline.").css({ 'color': 'red', 'font-weight': 'bold' });
                }

                if ($(this.compareTime(srdi, cdi)) && cdi != '') {
                    $('.secondClientValMsg').html("Second Review Deadline is greater than Client Deadline.").css({ 'color': 'red', 'font-weight': 'bold' });
                }
        },
        compareTime: function (time1, time2) {
        return new Date(time1) > new Date(time2); 
        },
        concatenateDateTime: function (date, time) {
            if(date != ''){
            var datetime = new Date(Date.parse(date + ' ' + time));

            var month = datetime.getMonth() + 1;
            var day = datetime.getDate();
            var year = datetime.getFullYear();

            var hour = datetime.getHours();
            if (hour < 10)
                hour = "0" + hour;

            var min = datetime.getMinutes();
            if (min < 10)
                min = "0" + min;

            var sec = datetime.getSeconds();
            if (sec < 10)
                sec = "0" + sec;

            var dateTimeString = month + '/' + day + '/' + year + ' ' + hour + ':' + min + ':' + sec;
          
            return dateTimeString;
            }
          },

Open in new window

0
Comment
Question by:Scott Baldridge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 2000 total points
ID: 41768379
You use the result of the method concatenateDateTime as a selector for jquery, this gives the error.

replace this
frdi = $(this.concatenateDateTime(frdiD, frdiT));

Open in new window

with this
frdi = this.concatenateDateTime(frdiD, frdiT);

Open in new window

You need to change other statements like this as well of course...
2
 

Author Closing Comment

by:Scott Baldridge
ID: 41768825
Thank you!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question