Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 11:18 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default comparing date/time fields on form validation

Hi there

I have a form which needs validating. I have done most of the validation but am scratching my head regarding 2 of my fields: 'start date/time' and 'end date/time'. Obviously the end date/time cannot be less than the start date/time but i'm not sure how to go about comparing these 2 fields. The format for both fields is 'dd/mm/yyyy hh:mm:ss'.

Any help or pointers in the right directions would be greatly appreciated.

Thanks in advance

Lucy xx

 
Old June 20th, 2006, 09:22 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Lucky!!
<script>
function calldate()
{
dateformat='dd/mm/yyyy hh:mm:ss'

D = '17/11/2006 05:30:43'

D=new Date(2006,11,19,5,30,43) //year, month, day, hour, minute, and seconds
d1=(D.getTime())
D=new Date(2006,11,18,5,30,43) //year, month, day, hour, minute, and seconds
d2=(D.getTime())
alert(d1>d2)
}
</script>
<input type=button onclick="calldate()">


plz adjust ur dateformat string while createing new Date() before assigining it to D=new Date( ) function

hope this will help you


Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
date time validation artarasan JSP Basics 2 December 4th, 2007 05:38 AM
Filter form with date fields problem!! chiefouko Access 2 August 14th, 2006 10:15 AM
setting date/time fields back to null value badgolfer Access 1 August 8th, 2005 02:29 AM
Trouble with comparing date fields JimmyNeutron Access VBA 3 February 22nd, 2005 09:14 AM
comparing CLOB fields pankaj_daga Access 0 August 5th, 2004 04:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.