Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date comparison

Posted on 2000-03-07
4
Medium Priority
?
134 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
[X]
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
  • 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 150 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

610 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