emm 8
New Member
Hi to everybody! I want to compare current date (server date) to the date inputted by the user. It should detect if inputted date is earlier than or equal to the current date.
For example:
Current date is 3/6/3008
Inputted Date by the user is 03/05/2008
Below is my function: -
function checkDateInput(dateString){
-
var error="";
-
with(currDate){
-
currDate = getMonth()+1+"/"+getDate()+"/"+getFullYear();
-
}
-
-
if(dateString != ""){
-
if(currDate >= dateString){
-
error = "Publication Date must not earlier than or equal to current date.";
-
return error;
-
}
-
}
-
return error;
-
}
-
Please help me. Thanks in advance and More Power!
5 2085 acoder 16,027
Recognized Expert Moderator MVP
Use the Date() object to compare dates, see for example, this link.
rnd me 427
Recognized Expert Contributor
Use the Date() object to compare dates, see for example, this link.
that wont validate by the server date, it uses the user's system's date, which can be more easily forged.
you will need to use a very simple xmlHtttpRequest to grab the server date.
would you like that code?
acoder 16,027
Recognized Expert Moderator MVP
that wont validate by the server date, it uses the user's system's date, which can be more easily forged.
That's right, but I did mean the JavaScript Date() object being set from the server whilst the page was loading, though an XMLHttp request would perhaps be more accurate (if the user happened to be on the page for more than one day!).
rnd me 427
Recognized Expert Contributor
That's right, but I did mean the JavaScript Date() object being set from the server whilst the page was loading, though an XMLHttp request would perhaps be more accurate (if the user happened to be on the page for more than one day!).
how would the Date object be affected by the server date?
i don't see how it has anything to do with page visit length, though i could be mis-understanding something.
if my clock is off, due to hacking or a bad CMOS battery for instance, the Date object will reflect that incorrect date.
this code gets a valid date object using the server's date: - function serverDate() {
-
X = !window.XMLHttpRequest ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest;
-
X.open("GET", window.location, false);
-
X.send("");
-
return Date(X.getResponseHeader("Date"));
-
}
-
acoder 16,027
Recognized Expert Moderator MVP
how would the Date object be affected by the server date?
i don't see how it has anything to do with page visit length, though i could be mis-understanding something.
if my clock is off, due to hacking or a bad CMOS battery for instance, the Date object will reflect that incorrect date.
I know that. I meant setting the Date object using server-side code, either using the Date() constructor or the set*** methods. If the user was for some reason still on the same page the next day, the date would now be off by one day (very unlikely, of course, but all the same...)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Scott Knapp |
last post by:
Good Day -
I have a form which sets the current date, as follows:
<script type="text/javascript">
xx=new Date()
dd=xx.getDate()
mm=xx.getMonth()+1
yy=xx.getYear()
mmddyy=mm+"/"+dd+"/"+yy
document.write(mmddyy)
|
by: alexis |
last post by:
Hi,
In a form I have the curent date
<input name="datetoday" type="hidden" value="<? echo date("d/m/Y"); ?>">
and
<input type=text name="datebox" size=15>
The date format is d/m/Y (day/month/year) in both case
Now my problem is that i want to know if 'datebox' is valid, that means
after 'datetoday'.
|
by: Richard Hollenbeck |
last post by:
I'm trying to write some code that will convert any of the most popular
standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan
1908) and compare the first with the second and calculate days, months, and
years. This is not for a college course. It's for my own personal
genealogy website. I'm stumped about the code. I'm working on it but not
making much progress. Is there any free code available anywhere? I know it...
|
by: Rich |
last post by:
Thanks for the Help in my previous post.
I've been working on this and it's almost what I want.
I want to obtain the user's current age by comparing their date of birth
(user inputs) to the current date.
I know how to get the Current Date but I'm not finding how to calculate the
Current Date minus the User's Birthday.
|
by: Rimuen |
last post by:
Have two text form with dates i need to compare before submitting, the
second should always be a date later the first one.
Anyone have a script for this ??
Thanks.......
| |
by: Tom |
last post by:
It appears that you can't compare two dates in DotNet. You must use
ToString and compare the strings. Is that the only reliable way?
Try this:
Dim dteOne As Date = FileDateTime(Application.ExecutablePath)
Dim dteTwo As Date = FileDateTime(Application.ExecutablePath)
SaveSetting("Test", "Dates", "DateThree",
FileDateTime(Application.ExecutablePath))
Dim dteThree As Date = CDate(GetSetting("Test", "Dates",
|
by: Peter |
last post by:
ASP.NET 1.1, this is a Intranet application and runs only on IE.
I have two webform text boxes which contain dates - starting date and ending
date. The dates could be in any format.
for example:
Starting date: 02/15/2006
Ending date: March 2006
I have to make sure the starting date is before the ending date
|
by: joeyej |
last post by:
How do I compare today's date with this string (in my inc file) so that
I can set an alert if date choice i.e. May 15, 2006 not at least
greater than two days from current date?
<option value="May 15, 2006, (Monday), 10am">May 15, 2006, (Monday),
10am
Thanks,
Joe
|
by: Assimalyst |
last post by:
Hi,
I have a working script that converts a dd/mm/yyyy text box date entry
to yyyy/mm/dd and compares it to the current date, giving an error
through an asp.net custom validator, it is as follows:
function doDateCheckNow(source, args)
{
var oDate = document.getElementById(source.controltovalidate); //
dd/mm/yyyy
|
by: balakrishnan.dinesh |
last post by:
hi frnds,
Im having two 20digit numbers, But while comparing those it
is giiving wrong ouput in javascript.
for example here is my code,
my secanrio is ,
~ If first 20 digit number is greater number than second 20 digit
number ,then it should return.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |