function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael DsozaMichael Dsoza 

how to make first letter of each as capital

How to make first letter of each word of sentence should be capital in visualforce ?

I have used apex:outputtext to show my text then how can i show it ?

I know LOWER is used for lowercase & UPPER is used for uppercase.

kritinkritin

Hi ,

 

I think for this you need to play with your string. means you need to pull first character from the word usting substring method of string and then use the Uppercase and then concatinate the string.

vishal@forcevishal@force

Hi, 

here is a small example of how you can do it.

 

string s1 = 'abc';
string s2 = s1.subString(0,1).toUpperCase();

system.debug(s2);

 

 

in my debug log, i will get "A".

 

with s1.subString(0,1) : here i am taking out the character  beginning at position 0 and ending at 1, which is the first character a.

then with the help of toUpperCase, i am displaying it as A.

 

Hope this helps.

AmitSahuAmitSahu

You can try using the below code in a class and use the value in VF.

 

String yourfielddata='This is a test';
String[] s= yourfielddata.split(' ');
 Integer 	i=0;
List<String> newString =  new List<String>();
for(String str:s)
{
i=str.length();
  String x,y,finalstring;
	x= str.substring(0,1).toUpperCase();
	y= str.substring(1,i) ;
	finalstring = x + y  ;
newString.add(finalstring);
}
String xyz= String.valueOf(newString);
String fxyz =xyz.replace(',','');

 "fxyz"  should be your final value in the vf {!fxyz}   

 

I hope this helps.

 

Regards,

Michael DsozaMichael Dsoza

Yaa every one is right in terms of my requirement but I already used the value on VFPage & how can i write the above code that u have mentioned.

I want direct way in visual force to change it so please tell me is their any function in visualforce that can i use directly...

like if you use LOWER(string) in visualforce then it will show value in visual force as small value.

Same I need for first letter as caps & rest of the small...

kritinkritin

In this scenario you can achieve it through adding javascript event...example

http://www.mediacollege.com/internet/javascript/text/case-capitalize.html

AmitSahuAmitSahu

Yes, write a javascript function in your VF page. Just below <apex:page> tag use <Script> javascript function(write your code here)</Script>.  Call the function on render of your pageblock.