Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 9th, 2003, 05:08 AM
kohsh kohsh is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Laun,TAS, AUS
Posts: 21 kohsh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to kohsh Send a message via Yahoo to kohsh
Date Validation by Javascript

I have two fields in a forom which are start date and end date, I want to check the end date cannot be early than the start date, I able to do it by using the code below but when I select single digit day and two digit day, it cannot compare, such as 5 and 20, even though 20 is later than 5 but it still prompt error.

Can javascript compare single digit and two digits or not?


function validateForm()
{
if (bookingform.endtime.value<=bookingform.starttime.value)
{
alert('Your End Hour must later than the start hour.')
bookingform.endtime.focus()
return false
}


if( (bookingform.rep_type[1].checked) || (bookingform.rep_type[2].checked) )
{
if((bookingform.rep_end_year.value==bookingform.ye ar.value) && (bookingform.rep_end_month.value==bookingform.mont h.value))
{
if(bookingform.rep_end_day.value<=bookingform.day.value)
{
alert("Your repeat end day must later than the start day")
bookingform.rep_end_day.focus()
return false
}
}

if ((bookingform.rep_end_year.value==bookingform.year .value) && (bookingform.rep_end_month.value<bookingform.month.value))
{
alert('Your Repeat End Month must later than the Start Month')
bookingform.rep_end_month.focus()
return false
}


if(bookingform.rep_end_year.value<bookingform.year.value)
{
if(bookingform.rep_end_month>bookingform.month.value)
{
alert("Your repeat end year must later than the start year")
bookingform.rep_end_year.focus()
return false
}
}


var aa=((bookingform.rep_end_year.value)-(bookingform.year.value));
if(aa>=2)
{
alert("Hello world")
return false
}
}
return true;
}

Reply With Quote
  #2  
Old September 9th, 2003, 05:10 PM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: Date Validation by Javascript

Why dont you try out writing your own function for converting your dates to timestamps.. It will be easy for comparison then.. Not a high end one.. Just a basic one

Somthing like

TmStamp=Day+Month+Year

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Date Validation by Javascript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway