Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I loop through submitted form field and make Proper Case?

Status
Not open for further replies.

jruiseco

Programmer
Joined
Oct 10, 2001
Messages
52
Location
US
I need to loop through the contents of a submitted form field and check/change to proper case. The field is an address field.

Example:
User submits this... 1234 main street
I want it to become this... 1234 Main Street

All I have so far is this:

<UCase(Left(Trim(address1),1)) & LCase(Mid(Trim(address1),2,999))>

...which addresses the first word in the sequnce. I'm having trouble figuring how to loop this and get to the 2..3..4... word. Also, the loop needs to ignore numbers.

BTW, I'm using CF 4.5 so a UDF is not an option for me.

Thanks....
 
<cfset listName=&quot;one two three four five six seven...&quot;>


<cfloop index=&quot;upperCase&quot; list=&quot;#listName#&quot; delimiters=&quot; &quot;>
<cfset listName=Replace(listName, upperCase, Replace(upperCase, Left(upperCase,1), Ucase(Left(upperCase,1))))>
</cfloop> Sylvano
dsylvano@hotmail.com
 
That's great.

But how would alter your script to check for lower case letters after the first letter?

This:
a froG iS in tHe tREe

Becomes this:
A Frog Is In The Tree


 
<cfset listName=Replace(listName, upperCase, Ucase(Left(upperCase,1))&RemoveChars(LCase(upperCase), 1, 1))>


will return this: A Frog Is In The Tree

is this what u r looking for? Sylvano
dsylvano@hotmail.com
 
That's it....

Cheers,

Josen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top