Only one problem with this code

<cfif isDefined("form.Year") and isDefined("form.Month") and isDefined("
form.Day")>
 <cfif IsDate(CreateDate(form.year,form.month,form.day))>
  Date Valid
 <cfelse>
  Date is invalid
 </cfif>
</cfif>


If the data entered into either of the three form fields is invalid,
the CreateDate will throw an error before the IsDate can do it's job.


It would be better to pull this out into a try catch

<cftry>
     <cfset variables.tempDate = CreateDate(form.year,form.month,form.day)>

     <cfcatch type="any">
          <cfset variables.dateError = true>
     </cfcatch>
</cftry>




On 6/15/07, Andrew Scott <[EMAIL PROTECTED]> wrote:
> How about.
>
> <cfif isDefined("form.Year") and isDefined("form.Month") and isDefined("
> form.Day")>
>  <cfif IsDate(CreateDate(form.year,form.month,form.day))>
>    Date Valid
>  <cfelse>
>    Date is invalid
>  </cfif>
> </cfif>
>
>
> On 6/16/07, Robert Harrrison <[EMAIL PROTECTED]> wrote:
> >
> > I validate dates all the time, but in this case I have to combine three
> > separate fields and validate if the date is valid.
> >
> > code is:
> >
> > <cfif IsDate(form.day/form.month/form.year) is false>
> >    BAD DATE
> > </cfif>
> >
> > Anyone see what's wrong here. It's not validating.
> >
> >
> >
> >
> >
> > Robert B. Harrison
> > Director of Interactive services
> > Austin & Williams
> > 125 Kennedy Drive, Suite 100 Hauppauge NY 11788
> > T : 631.231.6600 Ext. 119
> > F : 631.434.7022
> > www.austin-williams.com
> >
> > Great advertising can't be either/or... It must be &.
> >
> >
> > No virus found in this outgoing message.
> > Checked by AVG Free Edition.
> > Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
> > 11:31 AM
> >
> >
> >
> >
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ 

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:281345
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to