User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,435 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,852 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 395 | Replies: 3 | Solved
Reply
Join Date: Jul 2008
Posts: 8
Reputation: us12 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
us12's Avatar
us12 us12 is offline Offline
Newbie Poster

urgent help needed pls..............

  #1  
Jul 24th, 2008
hi all,
i need a code for date comparision,my requirement is first we have to enter start date and when we enter end date it should check whether the date is greater than the start date or not if it is greater only it should alow otherwise it shoud alert........

for ex : if i entered start date as 20/07/2008
it shoudl accept the next dates like 21/07/2008 or later
but should not accept 19/07/2008
i hope u got my point.............

so pls. help me thanx in adv
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Posts: 108
Reputation: Thirusha is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 12
Thirusha Thirusha is offline Offline
Junior Poster

Re: urgent help needed pls..............

  #2  
Jul 24th, 2008
i understand what u need to do, but what have u done, can we look at some code that u have done.
Reply With Quote  
Join Date: Apr 2007
Posts: 251
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

Re: urgent help needed pls..............

  #3  
Jul 24th, 2008
var now = new Date(); 
      var today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); 
      var user_dt=document.getElementById("ctl00_ContentPlaceHolder1_txtcanndate").value;
      var dd=parseInt(user_dt.substring(0,2),10);
      var mon=parseInt(user_dt.substring(3,5),10);
      var yr=parseInt(user_dt.substring(6,10),10);
      var userDate = new Date(yr,mon,dd); // Get user date in mm/dd/yyyy format
   
    if(today.getDate() > userDate.getDate())
    {
       alert("Announcement date is less than Today's");
      
	   return false;
    }

u can change u r code based on the above code
Last edited by Tekmaven : Jul 25th, 2008 at 1:08 pm. Reason: Code tags
Reply With Quote  
Join Date: Jul 2008
Posts: 8
Reputation: us12 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
us12's Avatar
us12 us12 is offline Offline
Newbie Poster

Re: urgent help needed pls..............

  #4  
Jul 25th, 2008
thnx for ur reply , i did my code like this..........

i got the output.............
<html>
<head>
<title>Compare Dates</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<Script Language=Javascript>
function CompareDates()
{
   var str1  = document.getElementById("fromdate").value;
   var str2  = document.getElementById("todate").value;
   var dt1   = parseInt(str1.substring(0,2),10);
   var mon1  = parseInt(str1.substring(3,5),10);
   var yr1   = parseInt(str1.substring(6,10),10);
   var dt2   = parseInt(str2.substring(0,2),10);
   var mon2  = parseInt(str2.substring(3,5),10);
   var yr2   = parseInt(str2.substring(6,10),10);
   var date1 = new Date(yr1, mon1, dt1);
   
   alert(date1);
   var date2 = new Date(yr2, mon2, dt2);

   if(date2 < date1)
   {
      alert("To date cannot be greater than from date");
      return false;
   }
   else
   {
      alert("Submitting ...");
      document.form1.submit();
   }
}

</Script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="">
<input type="text" name="fromdate" id="fromdate" value="20/10/2005">
<input type="text" name="todate" id="todate" value="19/10/2005">
<input type="button" value="compare dates" onclick="CompareDates()">
</form>
</body>
</html>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 12:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC