Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var CurrentDate = CurrentDate();
this line message appear object expected
Please help me.

C#
function Check_ToDate(obj) {
           var txtPrevDate = gebi("ctl00_cph1_txtPrevDate");
           gebi('divDate').style.display = "none";
           //obj.className = "unwatermarked";
           //gebi('row').style.display = "block";
           if (gebi(obj).value != "Please type here...") {
               var arrPreDate = gebi(obj).value.split(" ");
               var Date = arrPreDate[1] + " " + arrPreDate[0] + " " + arrPreDate[2];

               var CurrentDate = CurrentDate();
               if (Date.parse(Date) > (Date.parse(CurrentDate))) {
                   gebi('divDate').innerHTML = "<img src='images/error.gif' alt='' />Previous date must not be greater than current date...";
                   gebi('divDate').style.display = "block";
                   obj.className = "unwatermarked_Error";
                   return false;
               }

           }
           return true;
       }
Posted

Try var currentDate = new Date();
 
Share this answer
 
Solution 1 is right that you have call Date function with a new and there is no CurrentDate function in Javascript for getting current date

so for getting current date you have to use
var CurrentDate = new Date();


Now for comparing two separate date you can directly compare two date objects just as shown in below example

C#
var x=new Date();
x.setFullYear(2013,03,02);
var today = new Date();
if (x>today)
{
  alert("Today is before 2nd March 2013");
}
else
{
  alert("Today is after 2nd March 2013");
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900