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
Solved

Date comparison

Posted on 2000-03-07
4
127 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
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 elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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)

809 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