Simple way to check for valid date?

2003-12-05 Thread Mike Kear
I have a form where users enter dates by selecting from drop-down menus for
date, month and year.Is there a simple way to check they have entered a
valid date rather than a laborious checking for leap year, if the month is
april and date greater than 30 etc etc etc?

I get errors if they choose 31 September or 30 February etc as you'd expect
but I'd rather handle the error gracefully than just display a nasty
database error. 



Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Simple way to check for valid date?

2003-12-05 Thread Dan Farmer
How about this

Take the form values... form.theyear form.themonthmm
form.theday dd

submit the form to a temporay page where you will combine them into one 
form.thedate ( but this time use the input type=hidden 
name=thedate_date value=enter the date validation tag.

Write out all the form variables ( set them again in that temp page ) and 
use _javascript_to point to your real form processing page.

script
form.submit();
/script



I have a form where users enter dates by selecting from drop-down menus for
date, month and year.Is there a simple way to check they have entered a
valid date rather than a laborious checking for leap year, if the month is
april and date greater than 30 etc etc etc?



I get errors if they choose 31 September or 30 February etc as you'd expect
but I'd rather handle the error gracefully than just display a nasty
database error.







Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks.









 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Simple way to check for valid date?

2003-12-05 Thread Michael Wolfe
cfif not IsDate(9/31/2003)
 !--- error code goes here ---
/cfif

 
--
Michael Wolfe
[EMAIL PROTECTED] 

-Original Message-
From: Mike Kear [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2003 12:49 AM
To: CF-Talk
Subject: Simple way to check for valid date?

I have a form where users enter dates by selecting from drop-down menus for
date, month and year.Is there a simple way to check they have entered a
valid date rather than a laborious checking for leap year, if the month is
april and date greater than 30 etc etc etc?

I get errors if they choose 31 September or 30 February etc as you'd expect
but I'd rather handle the error gracefully than just display a nasty
database error. 

Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks. 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Simple way to check for valid date?

2003-12-05 Thread Mike Kear
YOU'RE KIDDING!!!I looked at that function and came to the conclusion it
wasn't for that, but for checking that the format of the string was really a
date.Cool. It checks the calendar too.

Sometimes the most simple answers are sitting right in front of you and
staring you in the face. 

Thanks Michael. 



Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks.





-Original Message-
From: Michael Wolfe [mailto:[EMAIL PROTECTED] 
Sent: Friday, 5 December 2003 8:58 PM
To: CF-Talk
Subject: RE: Simple way to check for valid date?

cfif not IsDate(9/31/2003)
 !--- error code goes here ---
/cfif

--
Michael Wolfe
[EMAIL PROTECTED] 

-Original Message-
From: Mike Kear [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2003 12:49 AM
To: CF-Talk
Subject: Simple way to check for valid date?

I have a form where users enter dates by selecting from drop-down menus for
date, month and year.Is there a simple way to check they have entered a
valid date rather than a laborious checking for leap year, if the month is
april and date greater than 30 etc etc etc?

I get errors if they choose 31 September or 30 February etc as you'd expect
but I'd rather handle the error gracefully than just display a nasty
database error. 

Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks. 
_

_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: Simple way to check for valid date?

2003-12-05 Thread Michael Wolfe
Let me qualify my answer...

 
IsDate checks for a valid date, but CF has funny notions about valid dates.
Basically, you can enter almost any value you want for the year part of the
date, and CF will accept if. So... you need to check if the date is within a
valid range also.

 
I have recently had a need to use this in a medical billing app I am working
on. Since some of the patients are over 100 years old, I use a function like
this:

 
cfif not IsDate(birthdate) or Abs(DateDiff(, birthdate, Now()) GT
120)
 !--- error code here ---
/cfif

 
--
Michael Wolfe
[EMAIL PROTECTED] 

-Original Message-
From: Mike Kear [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2003 2:25 AM
To: CF-Talk
Subject: RE: Simple way to check for valid date?

YOU'RE KIDDING!!!I looked at that function and came to the conclusion it
wasn't for that, but for checking that the format of the string was really a
date.Cool. It checks the calendar too.

Sometimes the most simple answers are sitting right in front of you and
staring you in the face. 

Thanks Michael. 

Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks.



-Original Message-
From: Michael Wolfe [mailto:[EMAIL PROTECTED] 
Sent: Friday, 5 December 2003 8:58 PM
To: CF-Talk
Subject: RE: Simple way to check for valid date?

cfif not IsDate(9/31/2003)
 !--- error code goes here ---
/cfif

--
Michael Wolfe
[EMAIL PROTECTED] 

-Original Message-
From: Mike Kear [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 05, 2003 12:49 AM
To: CF-Talk
Subject: Simple way to check for valid date?

I have a form where users enter dates by selecting from drop-down menus for
date, month and year.Is there a simple way to check they have entered a
valid date rather than a laborious checking for leap year, if the month is
april and date greater than 30 etc etc etc?

I get errors if they choose 31 September or 30 February etc as you'd expect
but I'd rather handle the error gracefully than just display a nasty
database error. 

Cheers,

Michael Kear

Windsor, NSW, Australia

AFP Webworks. 
_

_ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]