Solved

Date comparison

Posted on 2000-03-07
4
122 Views
Last Modified: 2010-04-09
How can I compare a date entered in an edit box with the current date?
0
Comment
Question by:wariar
  • 3
4 Comments
 
LVL 8

Expert Comment

by:xabi
ID: 2592173
Read this:

http://developer.irt.org/script/16.htm

xabi

PS: If you need me to write the whole code just ask.
0
 
LVL 8

Accepted Solution

by:
xabi earned 50 total points
ID: 2592230
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkit() {
 dateString = document.myform.mydate.value
 dateType   = document.myform.format.options[document.myform.format.selectedIndex].value
 if (dateString != "") {
  var now = new Date();
  var today = new Date(now.getYear(),now.getMonth(),now.getDate());
  if (dateType == 1)      var date = new Date(dateString.substring(0,4),dateString.substring(4,6)-1,dateString.substring(6,8));
  else if (dateType == 2) var date = new Date(dateString.substring(6,10),dateString.substring(3,5)-1,dateString.substring(0,2));
  if (date < today) alert("Before today")
  else if (date > today) alert("After today")
  else alert("Today")
 } else {
  alert("Please give a day");
 }
}
//-->
</SCRIPT>
</head>
<body>
<form name="myform">
<input type="text" name="mydate">
<br>
<select name="format">
 <option value="1">This format: 19970529</option>
 <option value="2">This format: 29/05/1997</option>
</select>
<br>
<input type="button" value="check" onclick="checkit()">
</form>
</body>
</html>
0
 
LVL 8

Expert Comment

by:xabi
ID: 2592234
Bored, so here goes the code.

xabi
0
 

Author Comment

by:wariar
ID: 2597077
Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now