> Can anyone make a suggestion on the best/standard way to setup data
> entry for time.. Specifically for a entry field for an event start time.

> I've thought about a text box, but that would seem to allow too many
> mistakes for the data entry person.. I've considered drop down select
> boxes for hour, AM/PM and minutes.. But there must be a standard, best
> way to do this for database entry using CF (or maybe even javascript)
> Thanks in advance

Users are liable to find multiple drop-downs frustrating. For that matter,
single drop-downs can be very frustrating if they are especially long. For
instance, you don't want to have an event start date drop-down with one
entry for every minute of the day -- one entry for every five minutes is
even likely to be frustrating.

If you can assume that any given start or end time for an event will only
occur between certain hours and on the half or quarter hour ( i.e. from 9-5
mon-fri, every half hour ), then you might be able to get a drop down to a
reasonable size that users won't be horribly frustrated by them. In this
setup, I can double-tap the 2 key on my keyboard and instantly hit 2:30, so
it's actually fairly convenient ( more so than a text field ).

In failing that, the next best thing is probably going to be a text field.
You can validate this with javascript to make sure the text is in the format
HH:mm, however, you should also validate this on the server-side (
server-side validation really should be performed for anything, if for no
other reason to be certain the javascript conveniences are working properly
)... Something like this should generally work fairly well to determine if
what is entered is a valid time:

<cfset mytime = listtoarray(form.starttime,":")>
<cfif arraylen(mytime) neq 2
        or not isnumeric(mytime[1])
        or not isnumeric(mytime[2])
        or mytime[1] lt 1
        or mytime[1] gt 24
        or mytime[2] lt 1
        or mytime[2] gt 59>
        <cfthrow type="custom" message="Invalid start time">
</cfif>

Of course, there are regex methods of checking this and the like, i.e.

<cfif not REFindNoCase("[0-2]?[0-9]:[0-9]{2,2}",form.starttime)
        or listgetat(form.starttime,1,":") gt 24
        or listgetat(form.starttime,2,":") gt 59>
        <cfthrow ...>
</cfif>

It all depends on what you're comfortable with of course...

If you're not familiar with Regular Expressions ( the 2nd example ) and want
more info, there's also a [EMAIL PROTECTED] list which has some
fairly knowledgeable people on it, including Mike Dinowitz who maintains the
house of fusion. :)


hth

S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to