0 Replies Latest reply on Aug 6, 2007 9:30 AM by Nick201

    date validation

    Nick201 Level 1
      I am reading file and I would like to do date validation : mm/dd/yyyy format.
      I am using this code but if fails if I put the wrong year.I mean 5 digit year. Thanks

      <cffunction name="validDate" output="true" returntype="boolean">
      <cfargument name="myDate" type="string" required="true" />
      <cfargument name="mask" type="string" required="false" default="mm/dd/yyyy"/>

      <cfset date_arr = ArrayNew(2) />
      <cfset arr_index = 1 />
      <cfloop index="i" list="y,m,d">
      <cfset temp_i = Find(i, mask) />
      <cfloop index="j" from="#temp_i#" to="#Len(mask)#">
      <cfif Mid(mask,j,1) NEQ i OR j EQ Len(mask)>
      <cfset date_arr[arr_index][1] = temp_i />
      <cfset date_arr[arr_index][2] = IIf(j NEQ Len(mask), DE(j-temp_i), DE(j-temp_i+1)) />
      <cfset arr_index = arr_index + 1 />
      <cfbreak />
      <cfset CreateDate(Mid(myDate,date_arr[1][1],date_arr[1][2]),Mid(myDate,date_arr[2][1],date_arr[2 ][2]),Mid(myDate,date_arr[3][1],date_arr[3][2])) />
      <cfreturn true />
      <cfreturn false />