Solved

Date comparison

Posted on 2000-03-07
4
121 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
Comment Utility
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
Comment Utility
<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
Comment Utility
Bored, so here goes the code.

xabi
0
 

Author Comment

by:wariar
Comment Utility
Thanks.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

772 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

11 Experts available now in Live!

Get 1:1 Help Now