Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 19th, 2006, 11:18 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old June 20th, 2006, 09:22 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
date time validation artarasan JSP Basics 2 December 4th, 2007 04: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 08:14 AM
comparing CLOB fields pankaj_daga Access 0 August 5th, 2004 04:38 AM



All times are GMT -4. The time now is 06:49 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.