Hey you cfscript experts! I have an auto-capitalize script that I use
on my forms for capitalizing names and such. If the user enters
ALLCAPS, MiXedCaPs, or all lowercase, it will fix each word by
capitalizing only the first letter. The only problem is with those darn
Irish names such as O'Brien. Is there a way to modify this script so it
will capitalize anything after an apostrophe? (I won't even ask about
names like McDonald!)

Try it out and see what you think:

<cfoutput>
<p><b>Before:</b> <cfif isdefined("Form.Test")>#Form.Test#</cfif>
<p><b>After:</b> <cfif
isdefined("Form.Test")>#AutoCap(Form.Test)#</cfif>
</cfoutput>

<cfscript>
function AutoCap(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>

<p>
<form name="form1" method="post" action="TestCap.cfm">
<input type="text" name="Test">
<input type="submit" name="Submit" value="Submit">
</form>
</p>