Kamru,

Do you mean you have someone inputting a time (in a form field or something) 
and you want to make sure it's a valid 12-hour (or 24-hour) time value?

In that case, I'd say just treat it as a colon-separated list, and do something 
like the following:

<cfset Hours = ListGetAt(TimeField,1,":")>
<cfset Minutes = ListGetAt(TimeField,2,":")>
<cfif Len(TimeField) is not 5> <!--- only needed if user *must* enter a 
two-digit value for HH --->
   <cfset TimeValid = false>
<cfelseif not (isNumeric(Hours) and isNumeric(Minutes))>
   <cfset TimeValid = false>
<cfelseif Hours lte 0 or Hours gt 12> <!--- use 23 if you want 24-hour time --->
   <cfset TimeValid = false>
<cfelseif Minutes lt 0 or Minutes gt 59>
   <cfset TimeValid = false>
<cfelse>
   <cfset TimeValid = true>
</cfif>

Not the neatest way, by far; but it'll do the trick.

Matt

> Please let me know how to validate time input in HH:MM format (i.e. 
> not HH:MM:SS). I am using CF8. Thanks a bunch! 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

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

Reply via email to