Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
CFMadness #1
cfscript auto capitalize help
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>
CFMadness Guest
-
<cfscript> Auto Capitalizing Question
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,... -
CFSEARCH results sometimes capitalize title information
I have a Verity collection searching the pages from our website. I am able to index the collection, search it and display the results. However,... -
cfscript
since i cannot find the cf and java integration thread, gues i will post this here: i wrote a cfm with cfscript that utilizes java which connects... -
<cfscript> autocaps problem </cfscript> - betcha can't fix this!
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 and variables
I'm using cfscript against a COM object. In VB the paramater is passed like: Set oSegment = oTransactionset.CreateDataSegment('BEG')...



Reply With Quote

