First, I'll tell you up front that I am clueless when it comes to
cfscript. So I apologize if this question is off topic.

I have a nice little <cfscript> that capitalizes selected fields in my
form submissions. It looks like this:

<cfscript>
function CapFirst(str) {
var result = Trim(str);
var wordCount = ListLen(result," ");
var ProperString = "";
for(i=1;i LTE wordCount;i=i+1) {
ProperString = ProperString & " " & UCase(Left(ListGetAt(result,i,"
"),1)) & LCase(RemoveChars(ListGetAt(result,i," "),1,1));
} ProperString = Trim(ProperString);
return ProperString;}
</cfscript>

Then I display the results as follows:
#CapFirst(Session.Customer.Fir*stName)#

It works fantastic, except for some reason on my final form submission,
if someone enters an apostrophe in the field, it wants to repeat it 8
times. So the name "O'Brien" will look like "O''''''''brien". I can
live with the second character being lowercase, but the repeating
apostrophe's have to go. Why there is 8, I do not know. I am
capitalizing 7 fields, but it is not looping over them. So I'm not sure
why it is doing this.

Also, the amount of apostrophes returned depends upon the number of
words in that field. So "Bob's and Ed's" would appear as
Bob''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''s
And Ed''''''''''''''''s". (64 and 16 - multiples of 8)

Kinda strange! Any ideas?? Maybe adding an "if" statement to ignore the
apostrophe's??