Entries for month: January 2011

When TimeFormat() Can't Quite Give You What You Need

ColdFusion , CFML 7 Comments »

So today I got a call from one of my clients.  The app we built for her is an event management app, and one of its functions outputs a list of all the events, including the start and ending times for each event.  Those times are output using ColdFusion's TimeFormat() function like so:

#TimeFormat(event.startTime,"h:mm tt")# - #TImeFormat(event.endTime,"h:mm tt")#

...which (for example) comes out as:

10:00 AM - 1:30 PM

My client was calling because she was told (by the local style enforcer, I guess) that the university's publishing style dictates dropping the ":00" for times that start on the hour and to use "a.m." and "p.m." rather than "AM" or "PM".  She wanted to know if I could adjust the report output to meet the style.

I briefly tried to see if there was a way to change the mask parameters in TimeFormat() to get the desired format, with no luck.  A quick search online for a ready-made solution also didn't yield any results.  So I ended up doing this:

<cfset initialVals= "AM,PM,:00">
<cfset newVals= "a.m.,p.m.,">
...
#ReplaceList(TimeFormat(event.startTime,"h:mm tt"),initialVals,newVals)#
- #ReplaceLIst(TimeFormat(event.endTime,"h:mm tt"),initialVals,newVals)#

That did the trick, but if someone's got another way of handling it, please feel free to share.

Small Update to My jQuery textCounting Plugin

jQuery No Comments »

I suspect there aren't too many users of my textCounting jQuery plugin, but if you do happen to use it, I wanted to point out a small update I made to it today.

Previously, the plugin was configured by default to look for the letter or word limit for your textarea control in an attribute called "maxLength."  That used to be a safe attribute name because browsers did not enforce the maxlength attribute on textrareas, only single-line text inputs.  But that's no longer the case with Safari:  if you put a maxlength attribute value of "100" on a textarea, Safari will prevent a user from entering more than 100 characters in that textarea.

So I changed the default attribute setting in the plugin to "maxTextLength" to avoid this issue.  To avoid this issue with Safari, you can either download the updated plugin files, or simply use the settings option in the previous version of the plugin to change the attribute name used by the plugin on a case-by-case basis.  In either case, you'll have to make sure you use "maxTextLength" instead of "maxLength" as an attribute in your textareas.