Solved

Date comparison

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AJAX Wordpress Not Reading Variable 2 58
Date on a table 16 35
links not working 2 27
form isn't working is it missing a document 21 27
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

726 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